sql - Postgresql Multiple counts for one table - Stack Overflow
jeudi 3 avril 2014 à 19:17La même avec MariaDB (ou MySQL):
SELECT type, SUM((place = 'home')), SUM((place = 'school')), … FROM reports GROUP BY type
Comme indiqué ici: http://stackoverflow.com/a/17086564, c'est parce que true casté en int vaut 1 (et false vaut 0)
(Permalink)
SELECT type, SUM((place = 'home')), SUM((place = 'school')), … FROM reports GROUP BY type
Comme indiqué ici: http://stackoverflow.com/a/17086564, c'est parce que true casté en int vaut 1 (et false vaut 0)
(Permalink)