Skip to main content
2 de 5
adicionou 4 caracteres ao conteúdo
José Dız
  • 7mil
  • 2
  • 18
  • 30

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, 
       Porcentagem= (cast(Passed as decimal(9,2)) / Total) 
  from totVWDADOSFPY
  order by Data desc;
José Dız
  • 7mil
  • 2
  • 18
  • 30