mysql - How to sum alias value if they are on same date and id? -


i want add values in column percent if department_id value same in same date.

here query try,

select date(r.date) date,         d.department_id,         ( ( select count(case when correct='yes' 1 end) )/100 * (select count(id) tbl_quest) ) percent    tbl_show r  left join  get_admin on (r.get_admin_id = a.admin_id)  left join get_department d on (a.department_id = d.department_id)  group r.date 

here result of above query:

date        department_id   percent      2015-11-17  3               0.1000 2015-11-17  1               0.5700 2015-11-17  3               0.2000 2015-11-18  1               0.5700 2015-11-18  1               0.0100 ........ 

now, want sum percent value if values same department id , same date.

i want change following result,

date        department_id   percent      2015-11-17  3               0.3000 2015-11-17  1               0.5700 2015-11-18  1               0.5800 ........ 

i appreciate suggestion.

try use group on date & department_id , select sum(percent).


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -