I have query that provides count of employee joined month wise across all cities. (In MySQL)
SELECT SUBSTR(`JoiningDate`,4,3) as Month,
Location,
Count(*) as `EmployeeCount`
FROM `data`
WHERE Location IN ('NYC','SFO','LA')
GROUP BY Month,Location
The output is in this format -
| Month|Location| Count|
-----------------------
| Jan | NYC | 100|
| Jan | SFO | 500|
| Jan | LA | 200|
| Feb | NYC | 100|
| Feb | SFO | 400|
| Feb | LA | 500|
How would i be able to transpose the data in a format, it produces columns for each city with relevant count per month? Something like below -
| Month|NYC |SFO | LA |
-----------------------
| Jan |100 |500 |200 |
| Feb |100 |400 |500 |
| Mar |300 |300 |650 |