Hi All,
I have included in the attached SQL:
Declare @table1 table ( cnsmr_id int, complainid int, complaintstat varchar(10) ) Insert into @table1 Select 1,1,'' UNION ALL Select 1,2,'dfs' UNION ALL Select 2,1,NULL select *from @table1 Where ISNULL(complaintstat,'') = '' SELECT SUM(Case When ISNULL(complaintstat,'') = '' Then 1 Else 0 End),COUNT(*) ,cnsmr_id FROM @table1 Group by cnsmr_id Having SUM(Case When ISNULL(complaintstat,'') = '' Then 1 Else 0 End) = COUNT(*)
The query should return only cnsmr_id=2 since all the complaints is closed (blank/NULL) i have achieved this using having but is there is more performance way of doing this?
Thanks,
Eshwar.