1
Hello. I need to make a mysql query with 3 Count in the same table. I got my results to appear below each other in the same column, but I need them to be in different columns.
It goes like this: I need to show the number of students enrolled in ballet classes, the number of students enrolled in jazz classes and the number of students enrolled in both classes. From the beginning of the year until today (04/09).
My query:
select count(*) as quantidade_ballet from alunos
where datamatricula>='2015-01-01%' and datamatricula<='2015-09-04%'
and (indballet=1 and indjazz=0)
union(select count(*) as quantidade_jazz from alunos
where datamatricula>='2015-01-01%' and datamatricula<='2015-09-04%'
and (indjazz=1 and indballet=0))
union(select count(*) as quantidade from alunos
where datamatricula>='2015-01-01%' and datamatricula<='2015-09-04%'
and (indjazz=1 and indballet=1));
PS: indballet and indjazz are the boolean indicators of which class the student is enrolled.
Can anyone help me ? Thank you.
Beauty @Guerra, it worked! Thank you!!!
– goldenleticia
Sync and corrections by n17t01
– Guerra