I'm trying to figure out how to count all presidents, managers etc and then convert columns to rows in one query. For example there is some sample db 'employee' here: http://www.mysqltutorial.org/tryit/ I can count employees of all types using query like this:
SELECT
SUM(CASE
WHEN jobTitle = 'President' THEN 1
ELSE 0
END) AS 'Presidents',
SUM(CASE
WHEN jobTitle LIKE 'VP%' THEN 1
ELSE 0
END) AS 'VPs',
SUM(CASE
WHEN jobTitle LIKE '%Manager%' THEN 1
ELSE 0
END) AS 'Managers',
SUM(CASE
WHEN jobTitle LIKE '%Rep' THEN 1
ELSE 0
END) AS 'Reps'
FROM
employees;
But now I want to convert columns to rows and I have no idea how to include it in a query similar to the answer here: Mysql Convert Column to row (Pivot table )