开发者

Mysql question, sum some field according to multiple employee id supplied in where clause

开发者 https://www.devze.com 2023-03-29 21:47 出处:网络
I want to sum some field of dat开发者_Go百科abase table according to the employee id supplied in where. The problem is I want to supply multiple employee ids in a single query and want the sum accordi

I want to sum some field of dat开发者_Go百科abase table according to the employee id supplied in where. The problem is I want to supply multiple employee ids in a single query and want the sum accordingly. Separate sum for each employee. please help me.


You will need to use the GROUP BY clause.

SELECT SUM(`hours`), `employee_id` FROM `timetable` WHERE `employee_id` IN (1, 3, 8, 52) GROUP BY `employee_id`;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号