0
A
回答
0
根據您在上面添加的要求,在這裏你可以做什麼
select Employee,FromDate=Min(AbsentDate),ToDate=Max(AbsentDate)
from(
select Employee,AbsentDate,count(*) over(partition by Employee,val) as AbsentDays,
dense_rank() over(partition by Employee order by val) as OrderId
from
(select Employee,AttendanceDate as AbsnetDate,dateadd(d,-row_number() over(partition by Employee order by AttendanceDate),AttendanceDate) as val
from TimeAttendance
where Status='Absent' -- assuming that if the employee didn't punch the Status will be 'Absent') t) x
where AbsentDays= n -- n is the n consecutive days
group by Employee
- 這裏的修正
select Employee,FromDate=Min(AbsentDate),ToDate=Max(AbsentDate)
from(
select Employee,AbsentDate,count(*) over(partition by Employee,val) as AbsentDays,
dense_rank() over(partition by Employee order by val) as OrderId
from
(select Employee,AttendanceDate as AbsentDate,dateadd(d,-row_number() over(partition by Employee order by AttendanceDate),AttendanceDate) as val
from TimeAttendance
where Status='Absent') as t -- assuming that if the employee didn't punch the Status will be 'Absent') t) x
)as x
where AbsentDays= n -- n is the n consecutive days
group by Employee
希望這將幫助你
問候
+0
查詢現在 – user3354807
+0
是它的工作原理返回了一個錯誤,謝謝你的回覆快 – user3354807
相關問題
- 1. 發現在員工考勤連續缺席註冊
- 2. TSQL在時間段內連續缺席連續缺席的人數
- 3. 更新連續缺席3天的個人
- 4. 獲得連續3天
- 5. 如何確定當天使用mysql缺席的員工人數
- 6. sql - 獲取連續的禮物和缺席
- 7. 獲取缺席記錄的值對每個員工
- 8. 從給定日期起連續獲得'N'個連續工作日
- 9. 獲得連續兩天的總和值
- 10. Sql服務器查詢找出員工何時缺席5天或更多
- 11. 我無法顯示缺席的多天
- 12. 連接兩個表來獲得出席和用戶名的mysql
- 13. 獲得每組最後[n,n + t]天
- 14. 如何查詢獲得連續排名?
- 15. 如何返回從表中「失蹤」行 - 員工缺席報告
- 16. 要計算每個員工的禮物和缺席
- 17. NHibernate如何獲得在以下n天有生日的會員
- 18. 我不得不採取在5名和次數每缺席
- 19. sql連續天
- 20. 如何獲得一年的在場和缺席的學生
- 21. 如何獲得連續順序的n組文檔Mongodb
- 22. 處理缺席JNDI
- 23. 如何獲得員工(資源)的工作日和缺勤日?
- 24. 獲得連續的行mysql
- 25. 單查詢,以獲得員工
- 26. Powershell獲得本月的第n天
- 27. 剛剛獲得記錄N天前
- 28. 獲得一家商店的在職員工名單
- 29. 如何在選擇部門時獲得員工名單?
- 30. 將學生缺席添加到一組學生缺席Ids
且存在他打了個這一天地位或不 – user3354807