CREATE PROCEDURE CBKTTMTOPYATTUANGMAKAN
(
	@EmployeeID VARCHAR(20)
	,@StartDate VARCHAR(20)
	,@EndDate VARCHAR(20)
	,@AttendanceType VARCHAR(20)
)
AS

--DECLARE @EmployeeID VARCHAR(20) = '00001000'
--DECLARE @StartDate VARCHAR(20) = '20230130'
--DECLARE @EndDate VARCHAR(20) = '20230205'
--DECLARE @AttendanceType VARCHAR(20) = '1000'

SELECT DISTINCT EmployeeID, COUNT(StartDate) AS TotAttendance FROM dbo.PHRPA0019
WHERE EmployeeID = @EmployeeID 
AND (StartDate BETWEEN @StartDate AND @EndDate)
AND AttendanceType = '1000'
GROUP BY EmployeeID