I have a table called registrations
from which I want to know the total count by city in the following layout.
Expected Layout
Tried preparing the below sql statement which gives me the correct information but not in the correct layout.
SELECT COUNT(IF(city LIKE '%location 1%',1, NULL)) 'LOCATION 1',
COUNT(IF(city LIKE '%location 2%',1, NULL)) 'LOCATION 2',
COUNT(IF(city LIKE '%location 3%',1, NULL)) 'LOCATION 3'
FROM registrations;
The layout from the above query.
Current Layout
How do I re-write the query to return the expected layout?