Há algumas formas. -- código #1 with totVWDADOSFPY as ( SELECT Data, SUM(CASE WHEN Status = 'OK' THEN 1 ELSE 0 END) as Passed, SUM(CASE WHEN Status = 'NOK' THEN 1 ELSE 0 END) as Failed, COUNT(*) AS Total from VWDADOSFPY group by Data ) SELECT Data, Passed, Failed, Total, Percent= (cast(Passed as decimal(9,2)) / Total) from totVWDADOSFPY order by Data desc;