SELECT DISTINCT
s.LastName + ',' + s.FirstName as formattedName
,t.Date
,t.In1
,RIGHT (t.In1, 7) AS TineIn1
,RIGHT (t.Out1, 7) AS TimeOut1
,RIGHT (t.In2, 7) AS TimeIn2
,RIGHT (t.Out2, 7) AS TimeOut1
,RIGHT (t.In3, 7) AS TimeIn3
,RIGHT (t.Out3, 7) AS TimeOut3
,SUM (
(t.In1-t.Out1)
+(t.In2-t.Out2)
+(t.In3-t.Out3)
) As WorkedHours
FROM employee e
JOIN StudentID_EmpID SID
ON e.EmpID = SID.EmpID
JOIN Student s
ON SID.StudentID = s.StudentID
AND s.StudentID = :parm_lb_StudenEE.studentID
JOIN Time t
ON s.StudentID = t.StudentID
WorkedHours 部分在尝试获得总工作时间时不起作用。我收到以下错误消息“SQL Server 的 Microsoft OLEDB 提供程序:操作数数据类型 datetime 对 sum 运算符无效”
我在数据库中的日期格式是 In1 1/1/1900 8:30:00 AM 和 Out1 1/1/1900 12:30:00 PM 等等。这就是我必须做“RIGHT (t.In1, 7) AS TineIn1”的原因,只是为了得到时间作为日期,这对我来说并不重要。
任何帮助将不胜感激。