Hi, I am executing a query different way in MSSQL, but the second query is not giving result as the first one.
Query 1:
select dbresultsid, TestCase, BuildID, Analyzed,
Verdict,
(select count(Verdict) from results where BuildID = 'Beta1'
and Verdict = 'PASS') AS PASS,
(select count(Verdict) from results where BuildID = 'Beta1'
and Verdict = 'FAIL') AS FAIL,
(select count(Verdict) from results where BuildID = 'Beta1'
and Verdict = 'INCONC') AS INCONC,
(select count(Verdict) from results where BuildID = 'Beta1'
and Verdict = 'TIMEOUT') AS TIMEOUT
from results
where BuildID = 'Beta1'
group by TestCase,dbresultsid
order by Analyzed
Query 2:
select dbresultsid, TestCase, BuildID, Analyzed,
Verdict,
(case when Verdict='PASS' then count(Verdict) else 0 end) as PASS,
(case when Verdict='FAIL' then count(Verdict) else 0 end) as FAIL,
(case when Verdict='INCONC' then count(Verdict) else 0 end) as INCONC,
(case when Verdict='TIMEOUT' then count(Verdict) else 0 end) as TIMEOUT
from results
where
BuildID = 'Beta1'
group by TestCase,dbresultsid
order by Analyzed
Results :
for Query 1:
if the total number of PASS = 20,
then PASS column will display 20 everywhere.
Results :
for Query 2:
here whereever there is PASS, it displays 1 and the total 20 rows where pass is displayed there is 1,
I want the results of query 2 to be same as query 1
any ideas please?
thanks,