select count(distinct clientid) as Reassessmentcount
from StateData
where grant='1234' and interview in ('3month','6month','12month','Discharge')
group by Grant,clientid
Reassessmentcount is 8 in the first sql statment
Select a.grant,sum(a.Baselinecount) as Bascount,sum(a.Reassessmentcount) as reassessmentcount from (
select Grant,
sum(case when interview='base' then 1 else 0 end) as Baselinecount,
sum(Case when interview in('3month','6month','12month','Discharge') then 1
else 0 end) as Reassessmentcount
from StateData
where grant='1234'
group by Grant,clientid
) A
Group by a.grantno
Reassessmentcount is 12 in the second sql statment
Correct value is 8, can someone please help me how to correct the second sql statement to show correct value.
Thanks.