mysql - Sql group by addition -
i have query pull records of 'consultant' 'marketing_fee'. results below :
is there way group them consultant (the middle column) add of marketing_fee's?
the code i'm using @ moment gets latest fees.
select a.marketing_fee, v.consultant, user.colorcode valuations v join status_history sh on sh.ref = v.ref join user on user.username = v.consultant join answer on a.title = v.ref sh.status = 'booked' , sh.date between '2016-09-07 23:59:00' , '2016-09-14 23:59:00'
is want?
select v.consultant, sum(a.marketing_fee) valuations v join status_history sh on sh.ref = v.ref join user on user.username = v.consultant join answer on a.title = v.ref sh.status = 'booked' , sh.date between '2016-09-07 23:59:00' , '2016-09-14 23:59:00' group v.consultant; 
Comments
Post a Comment