更新时间:2023-02-05 12:06:18
目前还不完全清楚为什么要检查行号以及为什么你有一个CTE。
从您描述的问题来看,这个简单的查询将为您提供所需的结果
It's not entirely clear why you are checking Row Numbers nor why you have a CTE.
From the problem as you have described it, this simple query will give you the results you need
select EmpId, SUM(DATEDIFF(MINUTE, Times_In, Times_Out)) / 60.0
from Emp_Attendance
where MONTH(Times_In) = 6
GROUP BY EmpId
请注意该部门的 .0
,以确保我们不会失去任何部分时间。
Note the .0
on the division to ensure we don't lose any partial hours.