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)
上下班记录在一块的查询语句,试旅绝一下吧。
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
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