求sql语句,两条记录合并为一条记录(考勤类)

2024-11-25 12:58:20
推荐回答(3个)
回答1:

select A.EmplID,A.RecDate,A.RecTime as 上班打卡时间,B.RecTime as下班打卡乎缓时间
FROM
(select * from 表岁镇模名 where EmplID+RecTime in (select EmplID+min(RecTime) from 表名 group by EmplID)
) A full outer join
(select * from 表名 where EmplID+RecTime in (select EmplID+max(RecTime) from 表名 group by EmplID
) B
on (A.EmplID=B.EmplID AND A.RecDate=B.RecDate)
上下班记录在一块的查询语句,试旅绝一下吧。

回答2:

select EmplID, ResultDate,
max(case InOutType when 0 then RecDate else '亩圆' end) as RecDate1,
max(case InOutType when 0 then RecTime else '乱耐渣' end) as RecTime1,
max(case InOutType when 1 then RecDate else '哗悄' end) as RecDate2,
max(case InOutType when 1 then RecTime else '' end) as RecTime2
from 表a
group by EmplID, ResultDate

回答3:

SELECT EmployeeName, Date, sum(Regular) AS WorkHours, Day, stuff
((SELECT '-' + ISNULL([TimeIn], '') + '-' + ISNULL([TimeOut], '')
FROM ViewFingerprintFormat t
WHERE EmployeeName = ViewFingerprintFormat.EmployeeName AND date = ViewFingerprintFormat.date FOR xml path('')), 1, 1, '') AS Times
FROM Table
GROUP BY EmployeeName, date, day