I have query like this
select t.Id,case when t.type ='19' then 'A1'
when t.type ='22' then 'A2'
else 'A3' End Actual_Type,count(t.type) record_count
from temp t
group by Id,t.type
Gives me results like this
ID Actual_type record_count
1 'A1' 1
1 'A3' 1
But I want records like this
ID Actual_type record_count
1 'A1' 1
1 'A2' 0
1 'A3' 1
for t.type = '22' there is no matching record in the table, but I want to return a record with 0 as value.
select t.Id,case when t.type ='19' then 'A1'
when t.type ='22' then 'A2'
else 'A3' End Actual_Type,count(t.type) record_count
from temp t
group by Id,t.type
Gives me results like this
ID Actual_type record_count
1 'A1' 1
1 'A3' 1
But I want records like this
ID Actual_type record_count
1 'A1' 1
1 'A2' 0
1 'A3' 1
for t.type = '22' there is no matching record in the table, but I want to return a record with 0 as value.