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: enter image description here

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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -