Advertisement
AlbertusMII

vcalendarlate isAllApproved

Nov 28th, 2023
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.79 KB | None | 0 0
  1. /****** Object:  View [dbo].[vcalendarlate]    Script Date: 28/11/2023 14:54:23 ******/
  2. SET ANSI_NULLS ON
  3. GO
  4.  
  5. SET QUOTED_IDENTIFIER ON
  6. GO
  7.  
  8.  
  9.  
  10.  
  11.  
  12. ALTER VIEW [dbo].[vcalendarlate]
  13. AS
  14. select employeeid,sum(late)Late,sum(EarlyOut)EarlyOut,sum(NoCheckIn)NoCheckIn,sum(NoCheckOut) NoCheckOut from (
  15. select a.EmployeeID,day(a.tgl) hari,a.tgl,a.Late,case when NoCheckOut = 0 then
  16. (case when datediff(MINUTE,a.timeout,b.jadwalkeluar) > 0 then 1 else 0 end)
  17. else 0 end EarlyOut,NoCheckIn,NoCheckOut from (
  18. SELECT distinct       ao.EmployeeID, 'H' AS tipe, convert(datetime,Date,105) AS tgl, isnull(timeIn,Date)TimeIn, ISNULL(TimeOut, Date) AS timeout,
  19.     'H In:' + ISNULL(left(CONVERT(varchar, TimeIn, 108),5), '-') + '  Out:' + ISNULL(left(CONVERT(varchar, TimeOut, 108),5), '-')
  20.     + '  Late:' + ISNULL(left(CONVERT(varchar, LateTimeDouble, 108),5), '00:00:00') AS note, 'limegreen' AS color,
  21.     case when LateTimeDouble <> 0 then 1 else 0 end Late,
  22.     case when timeIn is null then 1 else 0 end NoCheckIn,case when timeout is null then 1 else 0 end NoCheckOut
  23.     FROM dbo.AttendanceOverview ao left join attendance a on ao.attendanceoverviewid = a.attendanceoverviewid where a.isAllApproved = 1
  24. ) a inner join
  25. (
  26. SELECT    distinct    EmployeeID, 'A' AS tipe, tgl, convert(datetime,convert(varchar,tgl,105)+ ' ' + convert(varchar(8),masuk),105) jadwalmasuk,
  27.     convert(datetime,convert(varchar,case when masuk > keluar then dateadd(day,1,tgl) else tgl end,105)+ ' ' + convert(varchar(8),keluar),105) jadwalkeluar,
  28.     'A In:' + ISNULL(left(CONVERT(varchar, masuk, 108),5), '-') + '  Out:' + ISNULL(left(CONVERT(varchar, keluar, 108),5), '-') note,
  29.     'slategrey'  AS color, 0 Late FROM dbo.vwp where tipe = 'reguler' and tgl is not null) b on
  30.     a.EmployeeID = b.employeeid and a.tgl = b.tgl
  31. ) c group by EmployeeID
  32. GO
  33.  
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement