I have a table named Users. I am trying out to grab some data from it with the following query:
select name, lastname, gender, status, count(status = 'Trvl') as TrvlCount,
count(status != 'Trvl') as NotTrvlCount, count(id) as TotalCount
from Users
group by name, lastname, gender, dob;
The expected result would be 7 columns with unique name, lastname,gender, dob (to avoid duplicates) and sum of different statuses. But I cant rectify why all 3 count columns are showing the same value or same sum value?
Any idea guys? Thanks in advance.
group by name, lastname, gender, status.