Project

General

Profile

Feature #1832 » CKJLTMTOPYGETABSENCE.sql

Tri Rizqiaty, 12/01/2022 02:56 PM

 
1
ALTER PROCEDURE CKJLTMTOPYGETABSENCE
2
(
3
	@EmployeeID VARCHAR(20)
4
	,@StartDate VARCHAR(20)
5
	,@EndDate VARCHAR(20)
6
)
7
AS
8

    
9
--DECLARE @EmployeeID VARCHAR(20) = '21120023'
10
--DECLARE @StartDate VARCHAR(20) = '20221101'
11
--DECLARE @EndDate VARCHAR(20)  = '20221131'
12

    
13
SELECT DISTINCT CASE WHEN COUNT(wscal.DateSpecified) > 0 THEN COUNT(wscal.DateSpecified) ELSE 0 END  AS TotAbsence
14
FROM PHRPA0018 AS pa18
15
LEFT JOIN dbo.PHRPA0025 AS pa25
16
	ON pa25.EmployeeID = pa18.EmployeeID
17
	AND pa25.StartDate <= @EndDate AND pa25.EndDate >= @EndDate
18
LEFT JOIN dbo.PHRTMWSCAL AS wscal
19
	ON wscal.WorkScheduleType = pa25.WorkScheduleType
20
LEFT JOIN dbo.PHRTMDAYTYP AS daytype
21
	ON wscal.DayType = daytype.DayType
22
WHERE (pa18.EmployeeID = @EmployeeID OR @EmployeeID = '')
23
	AND wscal.DateSpecified BETWEEN pa18.StartDate AND pa18.EndDate
24
	AND daytype.Flag <> 'OFF'
25
	AND (pa18.StartDate BETWEEN @StartDate AND @EndDate OR pa18.EndDate BETWEEN @StartDate AND @EndDate)
26
	AND (wscal.DateSpecified BETWEEN @StartDate AND @EndDate)
(1-1/6)