Abhimanyu1310
Abhimanyu1310

Reputation: 71

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

I want to sum some field of database 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.

Upvotes: 0

Views: 162

Answers (1)

D_V
D_V

Reputation: 416

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`;

Upvotes: 3

Related Questions