我有一张名为leave的表:
leave_id employee_id dateApplied leaveStrtDate leaveEndDate no_of_days
3 1 2012-10-31 2012-10-10 2012-10-17 5
4 1 2012-10-31 2012-10-24 2012-10-17 10
现在我想使用mysql查询从no_of_days列添加值,例如:no_of_days的总和应为15.有没有办法在mysql查询中执行此操作?
答案 0 :(得分:3)
SELECT employeeID, sum(no_of_days) totalDays
FROM leave
GROUP BY employeeID
答案 1 :(得分:2)
select sum(no_of_days) from leave
答案 2 :(得分:0)
SELECT SUM(no_of_days) FROM leave;
您可以使用mysql sum函数
答案 3 :(得分:0)
select sum(no_of_days) from leave group by employee_id;
这将在休假表中获得每位员工的休假天数。
答案 4 :(得分:0)
Select SUM(no_of_days) from leave;