I'm trying to create a view to return the query from a Query. My problem is that I wanted it to return values for each product and it is returning the same value for the products.
SELECT B.ID_Caso, B.Nome_Caso_Teste AS PRODUTO,
(SELECT COUNT(Status_Execucao) AS Expr1
FROM dbo.Execucao
WHERE (Status_Execucao = 'PASSED')) AS PASSED,
(SELECT COUNT(Status_Execucao) AS Expr1
FROM dbo.Execucao AS Execucao_3
WHERE (Status_Execucao = 'FAILED')) AS FAILED,
(SELECT CAST(COUNT(Status_Execucao) AS float) AS
Expr1
FROM dbo.Execucao AS Execucao_2
WHERE (Status_Execucao = 'PASSED')) /
(SELECT COUNT(Status_Execucao) AS Expr1
FROM dbo.Execucao AS Execucao_1) * 100 AS
PROGRESSO
FROM dbo.Execucao AS A INNER JOIN
dbo.CasoTeste AS B ON A.ID_Caso = B.ID_Caso
GROUP BY B.Nome_Caso_Teste, B.ID_Caso
And it returns that way, with equal values for the products, and they have different data. It is consolidating the total and placing for the products.
ID_Caso PRODUTO PASSED FAILED PROGRESSO % 4 Condominio 13 5 72,2222222222222 3 Empresarial 13 5 72,2222222222222 2 Fiança Locatícia 13 5 72,2222222222222 1 Residenciais 13 5 72,2222222222222
Another problem is that it is bringing the Progress field broken by several decimal places, I wanted it to bring in whole. For example 72.2222222 = 72. I looked at the forum and could not solve my doubts. Can anyone point me a way forward?