开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜