MySQL SUM(GROUP BY) -
i trying add columns id same. i'm new mysql appears group by
need.
here attempt gives me syntax error
|siteid|staffid|holiday|total
update sitestaff set total = sum(h.holiday) group h.staffid
i suspect have holiday table. if so, want query uses join
update
, , looks this:
update sitestaff ss left join (select h.staffid, sum(h.holiday) total holidays h group h.staffid ) h on ss.staffid = h.staffid set ss.total = coalesce(t.total, 0);
Comments
Post a Comment