I have a status column which will only ever contain three distinct values. I need to get a count for each, but I need to output them on a single row. So rather than:
`status` | `count`
status1 | 100
status2 | 101
status3 | 102
I want:
`status1` | `status2` | `status3`
100 | 101 | 102
I'm sure there's an easy way to do this but I'm not seeing it.
edit: Managed to get it to work using an answer from Oracle sql to count instances of different values in single column:
SELECT
COUNT(CASE WHEN STATUS = 'STATUS1' THEN 1 ELSE NULL END) AS STATUS1,
COUNT(CASE WHEN STATUS = 'STATUS2' THEN 1 ELSE NULL END) AS STATUS2,
COUNT(CASE WHEN STATUS = 'STATUS3' THEN 1 ELSE NULL END) AS STATUS3
FROM TABLE