Last active
May 3, 2019 13:34
-
-
Save petdance/c17c148ce06c72a5324256f6e14c6c3f to your computer and use it in GitHub Desktop.
Gender counts per reason
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The MariaDB I installed doesn't support CTEs, so use a subquery */ | |
SELECT * FROM ( | |
select | |
reason, | |
SUM( CASE WHEN gender = 'Male' THEN 1 END) as M, | |
SUM( CASE WHEN gender = 'Female' THEN 1 END) as F, | |
SUM( CASE WHEN gender NOT IN ('Male','Female') THEN 1 END) AS X, | |
COUNT(gender) AS T | |
from response | |
inner join reasons on reasons.responseid = response.responseid | |
group by reason | |
) stats | |
order by T desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment