I am not able to get the proper count. I have 2 tables:
Tbl1
id | name | call |
---|---|---|
123 | aaaaaa | 15 |
132 | bbbbb | 0 |
Tbl2
id | involvement |
---|---|
123 | 0 |
123 | 0 |
123 | 1 |
I would like to get the count of ids where call = 15
and involvement = 0
. My query:
select t1.id,
COUNT(CASE WHEN t1.call=15 THEN 1 END) as calls
from Tbl1 t1
left join Tbl2 t2
on t2.id = t1.id
where t2.involvement = 0;
The result expected for count
is 1
.