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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -