Created
July 14, 2013 20:59
-
-
Save marcellobenigno/5996003 to your computer and use it in GitHub Desktop.
Exemplo de Pivot Table
This file contains hidden or 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
SELECT bairro, | |
sum(CASE WHEN sexo ='MASCULINO' THEN 1 ELSE 0 END) AS total_homens, | |
sum(CASE WHEN sexo ='FEMININO' THEN 1 ELSE 0 END) AS total_mulheres | |
FROM acidentes | |
GROUP BY bairro | |
ORDER BY total_homens DESC, total_mulheres DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment