mysql - Total of Male and Female in Grade 8 using sql, codeigniter -
i have problem total in yearlevel total number of male , female in grade 7:
i can count using codeigniter:
<h3> total students: <?php echo $this->db->count_all('studentinformation'); ?></h3>
and group them using this:
select yearlevel, sex, count(id) numgender studentinformation group sex, yearlevel
my problem count in yearlevel total of grade7, grade 8 , arrage them
perhaps you're looking for?
use case
expressions conditional counting:
select yearlevel, count(*) studentcount, count(case when sex = 'female' 1 end) femalecount, count(case when sex = 'male' 1 end) malecount studentinformation group yearlevel
Comments
Post a Comment