mysql - need absent and present count with month name -


i need month name absent , present count. database query:

select sid,count(case when status ='a' 1 end) absent_count,count(case when status ='p' 1 end) present_count,       monthname(attendance_date) `month_name`       attendance       sid = '2'       , campus_id = 2       group sid; 

there's no point in group sid - '2', per where clause. instead, since want count per month name, should appear in group by clause:

select   monthname(attendance_date) `month_name`,           count(case when status ='a' 1 end) absent_count,          count(case when status ='p' 1 end) present_count,     attendance    sid = '2' , campus_id = 2 group monthname(attendance_date); 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -