I need to export data of status from s.status
column like
x
select s.name,
count(CASE WHEN s.STATUS = 'Active' THEN 1 END) AS Active_count,
count(CASE WHEN s.STATUS = 'Expired' THEN 1 END) AS Expired_count,
count(CASE WHEN s.STATUS = 'In Progress' THEN 1 END) AS InProgress_count
from my.table s
group by s.name,s.status
I expect it to be counted in one row but instead I am getting smthing like this
https://i.stack.imgur.com/K4wyc.png
Can anyone help me write it so I can get the data in one row ?
Thank you
Advertisement
Answer
Remove s.status from your group by