Project

General

Profile

Bug #2904 » SP.txt

Muhammad Bintar, 07/19/2024 11:19 AM

 
1

    
2
ALTER PROCEDURE [dbo].[CRPTTMREKAPABSENSI_LPPOM]
3
    (
4
      @PayPeriod VARCHAR(18),
5
	  @EmployeeID VARCHAR(18)  
6
    )
7
AS 
8

    
9

    
10
--DECLARE @PayPeriod VARCHAR(6) = '202406'
11
--DECLARE @EmployeeID VARCHAR(18) = '23100084'
12

    
13
DECLARE @TMPeriodStartDate VARCHAR(8)
14
DECLARE @TMPeriodEndDate VARCHAR(8)
15
DECLARE @TMPeriodEndDateDt DATETIME
16

    
17
SET @TMPeriodStartDate = @PayPeriod + '01'
18
SET @TMPeriodEndDateDt = DATEADD(dd, -1,
19
                                 DATEADD(mm, 1,
20
                                         CONVERT(DATETIME, @TMPeriodStartDate)))
21
SET @TMPeriodEndDate = @PayPeriod + CONVERT(VARCHAR(2), DATEPART(dd,
22
                                                              @TMPeriodEndDateDt))
23

    
24
DECLARE @WSCAL TABLE
25
    (
26
      [WorkScheduleType] [varchar](8) ,
27
      [DateSpecified] [varchar](18) ,
28
      [DayType] [varchar](50) ,
29
      [StartTime] [varchar](8) ,
30
      [EndTime] [varchar](8)
31
    )
32
DECLARE @EMP TABLE
33
    (
34
      [EmployeeID] [varchar](8) NOT NULL ,
35
      [FullName] [varchar](250) ,
36
      [WorkScheduleType] [varchar](20)
37
    )
38
DECLARE @EMPLIST TABLE
39
    (
40
      [EmployeeID] [varchar](18) NOT NULL ,
41
      [FullName] [varchar](250) ,
42
      [DateSpecified] [varchar](18) ,
43
      [DayType] [varchar](50) ,
44
      [StartTime] [varchar](8) ,
45
      [EndTime] [varchar](8)
46
    )
47
DECLARE @ABSENCE TABLE
48
    (
49
      [EmployeeID] [varchar](18) NOT NULL ,
50
      [AbsenceType] [varchar](50) ,
51
      [TotalAbsenceTaken] [varchar](50) ,
52
      [StartDate] [varchar](50) ,
53
      [DayType] [varchar](50)
54
    )
55

    
56
DECLARE @SUM_ABSENCE TABLE
57
    (
58
      [EmployeeID] [varchar](18) NOT NULL ,
59
      [AbsenceType] [varchar](50) ,
60
      [Sum_Cuti] [varchar](50) ,
61
      [DayType] [varchar](50)
62
    )
63

    
64
DECLARE @SUM_IJIN_SAKIT TABLE
65
    (
66
      [EmployeeID] [varchar](18) NOT NULL ,
67
      --[AbsenceType] [varchar](50) ,
68
      [Sum_IjinSakit] [varchar](50) ,
69
      [DayType] [varchar](50)
70
    )
71
	DECLARE @sum_cuti TABLE
72
    (
73
		[TotalCuti] VARCHAR(18),
74
      [EmployeeID] [varchar](18) NOT NULL 
75
      
76
    )
77
DECLARE @dataABSENCE TABLE
78
    (
79
      [EmployeeID] [varchar](18) NOT NULL ,
80
      [C] [varchar](10) ,
81
      [I] [varchar](10) ,
82
      [A] [varchar](10)
83
    )
84
DECLARE @Attendance TABLE
85
    (
86
      [EmployeeID] [varchar](18) NOT NULL ,
87
      [DateSpecified] [varchar](8) ,
88
      [WSStartTime] [varchar](8) ,
89
      [WSEndTime] [varchar](8) ,
90
      [19StartTime] [varchar](8) ,
91
      [19EndTime] [varchar](8) ,
92
      [18DayType] [varchar](50) ,
93
      [FlagAtt] [varchar](8)
94
    )
95
DECLARE @dataAttendance TABLE
96
    (
97
      [EmployeeID] [varchar](18) NOT NULL ,
98
      [DateSpecified] [varchar](8) ,
99
      [WSStartTime] [varchar](8) ,
100
      [WSEndTime] [varchar](8) ,
101
      [19StartTime] [varchar](8) ,
102
      [19EndTime] [varchar](8) ,
103
      [SelisihMasuk] [varchar](8) ,
104
      [SelisihPulang] [varchar](8) ,
105
      [SelisihKerja] [varchar](8)
106
    )
107
DECLARE @dataNonAttendance TABLE
108
    (
109
      [EmployeeID] [varchar](18) NOT NULL ,
110
      [TA] [varchar](8) ,
111
      [TAM] [varchar](8) ,
112
      [TAP] [varchar](8)
113
    )
114
DECLARE @dataTelatMasuk TABLE
115
    (
116
      [EmployeeID] [varchar](18) NOT NULL ,
117
      [Telat<10] [varchar](8) ,
118
      [Telat>10] [varchar](8) ,
119
      [SelisihTelat] [varchar](20)
120
    )
121
DECLARE @dataMasukAwal TABLE
122
    (
123
      [EmployeeID] [varchar](18) NOT NULL ,
124
      [MasukAwal] [varchar](8) ,
125
      [SelisihMasuk] [varchar](20)
126
    )
127
DECLARE @dataPulangAwal TABLE
128
    (
129
      [EmployeeID] [varchar](18) NOT NULL ,
130
      [PulangAwal] [varchar](8) ,
131
      [SelisihPulang] [varchar](20)
132
    )
133
DECLARE @dataDurasiKerja TABLE
134
    (
135
      [EmployeeID] [varchar](18) NOT NULL ,
136
      [AVGKerja] [varchar](20) ,
137
      [SelisihKerja] [varchar](20)
138
    )
139

    
140
INSERT  INTO @WSCAL
141
        SELECT  wscal.WorkScheduleType ,
142
                wscal.DateSpecified ,
143
                wscal.DayType ,
144
                daytyp.StartTime ,
145
                daytyp.EndTime
146
        FROM    dbo.PHRTMWSCAL wscal WITH ( NOLOCK )
147
                INNER JOIN dbo.PHRTMDAYTYP daytyp ON wscal.DayType = daytyp.DayType
148
        WHERE   DateSpecified >= @TMPeriodStartDate
149
                AND DateSpecified <= @TMPeriodEndDate
150

    
151
--SELECT  *
152
--FROM    @WSCAL
153

    
154
INSERT  INTO @EMP
155
        SELECT DISTINCT
156
                md1.EmployeeID ,
157
                md1.FullName ,
158
                md25.WorkScheduleType
159
        FROM    dbo.PHRPA0001 md1 WITH ( NOLOCK )
160
                LEFT JOIN dbo.PHRPA0002 md2 WITH ( NOLOCK ) ON md1.EmployeeID = md2.EmployeeID
161
                INNER JOIN dbo.PHRPA0025 AS md25 WITH ( NOLOCK ) ON md1.EmployeeID = md25.EmployeeID
162
                                                              AND md25.StartDate <= @TMPeriodEndDate
163
                                                              AND md25.EndDate >= @TMPeriodStartDate
164
        WHERE   ( md1.EmployeeID = @EmployeeID
165
                  OR @EmployeeID = ''
166
                )
167
                AND md1.StartDate <= @TMPeriodEndDate
168
                AND md1.EndDate >= @TMPeriodStartDate
169
                AND md2.StartDate <= @TMPeriodEndDate
170
                AND md2.EndDate >= @TMPeriodStartDate
171
                AND md2.EmployeeStatus <> '04'
172

    
173
--SELECT  *
174
--FROM    @EMP
175

    
176
INSERT  INTO @EMPLIST
177
        SELECT  emp.EmployeeID ,
178
                emp.FullName ,
179
                wscal.DateSpecified ,
180
                wscal.DayType ,
181
                wscal.StartTime ,
182
                wscal.EndTime
183
        FROM    @EMP AS emp
184
                INNER JOIN @WSCAL AS wscal ON wscal.WorkScheduleType = emp.WorkScheduleType
185
				LEFT JOIN dbo.PHRTMDAYTYP daytype ON wscal.DayType=daytype.DayType AND daytype.EndDate='99991231'
186
		WHERE daytype.Flag='WORK'
187
                                              --AND wscal.DayType = 'WDAY'
188
--SELECT  *
189
--FROM    @EMPLIST
190

    
191
--SELECT * FROM dbo.PHRTMDAYTYP
192

    
193
INSERT  INTO @ABSENCE
194
        SELECT  md18.EmployeeID ,
195
                md18.AbsenceType ,
196
                md18.TotalAbsenceTaken ,
197
                emplist.DateSpecified ,
198
                emplist.DayType
199
        FROM    @EMPLIST AS emplist
200
                INNER JOIN dbo.PHRPA0018 AS md18 WITH ( NOLOCK ) ON emplist.EmployeeID = md18.EmployeeID
201
                                                              AND emplist.DateSpecified >= md18.StartDate
202
                                                              AND emplist.DateSpecified <= md18.EndDate
203
        WHERE   ( md18.StartDate BETWEEN @TMPeriodStartDate
204
                                 AND     @TMPeriodEndDate
205
                  OR md18.EndDate BETWEEN @TMPeriodStartDate
206
                                  AND     @TMPeriodEndDate
207
                )
208
                AND emplist.DateSpecified >= @TMPeriodStartDate
209
                AND emplist.DateSpecified <= @TMPeriodEndDate
210

    
211
INSERT  INTO @SUM_ABSENCE
212
        SELECT  md18.EmployeeID ,
213
                md18.AbsenceType ,
214
                SUM(md18.TotalAbsenceTaken) Sum_Cuti ,
215
                --emplist.DateSpecified ,
216
                emplist.DayType
217
        FROM    @EMPLIST AS emplist
218
                INNER JOIN dbo.PHRPA0018 AS md18 WITH ( NOLOCK ) ON emplist.EmployeeID = md18.EmployeeID
219
                                                              AND emplist.DateSpecified >= md18.StartDate
220
                                                              AND emplist.DateSpecified <= md18.EndDate
221
        WHERE   ( md18.StartDate BETWEEN @TMPeriodStartDate
222
                                 AND     @TMPeriodEndDate
223
                  OR md18.EndDate BETWEEN @TMPeriodStartDate
224
                                  AND     @TMPeriodEndDate
225
                )
226
                AND emplist.DateSpecified >= @TMPeriodStartDate
227
                AND emplist.DateSpecified <= @TMPeriodEndDate
228
                AND md18.AbsenceType IN ( '01', '02' )
229
        GROUP BY md18.EmployeeID ,
230
                md18.AbsenceType ,
231
              
232
                --emplist.DateSpecified ,
233
                emplist.DayType
234

    
235
INSERT INTO @sum_cuti
236
SELECT DISTINCT SUM(totalabsencetaken) AS total_cuti, EmployeeID
237
FROM    dbo.PHRPA0018
238
WHERE   
239
		 @PayPeriod = SUBSTRING(Startdate, 1, 6)
240
AND 
241
AbsenceType IN ( '01', '02' )   
242
GROUP BY EmployeeID 
243

    
244
--SELECT * FROM @EMPLIST
245

    
246
INSERT  INTO @SUM_IJIN_SAKIT
247
        SELECT DISTINCT md18.EmployeeID ,
248
        --md18.AbsenceType ,
249
                SUM(md18.TotalAbsenceTaken) Sum_Cuti ,
250
                --emplist.DateSpecified ,
251
                emplist.DayType
252
        FROM    @EMPLIST AS emplist
253
                LEFT JOIN dbo.PHRPA0018 AS md18 WITH ( NOLOCK ) ON emplist.EmployeeID = md18.EmployeeID
254
                                                              AND emplist.DateSpecified >= md18.StartDate
255
                                                              AND emplist.DateSpecified <= md18.EndDate
256
        WHERE   
257
		md18.AbsenceType IN ( '60', '61', '62','40' )
258
                AND ( md18.StartDate BETWEEN @TMPeriodStartDate
259
                                     AND     @TMPeriodEndDate
260
                      OR md18.EndDate BETWEEN @TMPeriodStartDate
261
                                      AND     @TMPeriodEndDate
262
                    )
263
                AND emplist.DateSpecified >= @TMPeriodStartDate
264
                AND emplist.DateSpecified <= @TMPeriodEndDate
265
        GROUP BY md18.EmployeeID ,
266
        --md18.AbsenceType ,
267
              
268
                --emplist.DateSpecified ,
269
                emplist.DayType
270

    
271

    
272
--SELECT  *
273
--FROM    @SUM_IJIN_SAKIT
274

    
275
--INSERT  INTO @ABSENCE
276
		--SELECT  md1018.EmployeeID ,
277
		--		'9999' ,
278
  --              --md1018.AbsenceType ,
279
		--		--CAST(md1018.TotalAbsenceTaken AS VARCHAR(8)) ,
280
		--		md1018.TotalAbsenceTaken ,
281
  --              emplist.DateSpecified ,
282
  --              emplist.DayType
283
  --      FROM    @EMPLIST AS emplist
284
  --              LEFT JOIN dbo.PHRPA1018 AS md1018 WITH ( NOLOCK ) ON emplist.EmployeeID = md1018.EmployeeID
285
  --                                                            AND emplist.DateSpecified >= md1018.StartDate
286
  --                                                            AND emplist.DateSpecified <= md1018.EndDate
287
  --      WHERE   ( md1018.StartDate BETWEEN @TMPeriodStartDate
288
  --                               AND     @TMPeriodEndDate
289
  --                OR md1018.EndDate BETWEEN @TMPeriodStartDate
290
  --                                AND     @TMPeriodEndDate
291
  --              )
292
  --              AND emplist.DateSpecified >= @TMPeriodStartDate
293
  --              AND emplist.DateSpecified <= @TMPeriodEndDate
294

    
295
--SELECT  *
296
--FROM    @ABSENCE
297

    
298
INSERT  INTO @dataABSENCE
299
        SELECT  tbl.EmployeeID ,
300
                SUM(tbl.C) + SUM(CONVERT(DECIMAL(18, 1), tbl.CS)) AS C ,
301
				--SUM(CONVERT(DECIMAL(18, 2),tbl.CS)) AS CS ,
302
                SUM(tbl.I) AS I ,
303
                SUM(tbl.A) AS A
304
        FROM    ( SELECT    ab.EmployeeID ,
305
                            CASE WHEN app.Value1 = 'C' THEN 1
306
                                 ELSE 0
307
                            END C ,
308
                            CASE WHEN app.Value1 = 'CS' THEN 0.5
309
                                 ELSE 0
310
                            END CS ,
311
                            CASE WHEN app.Value1 = 'I' THEN 1
312
                                 ELSE 0
313
                            END I ,
314
                            CASE WHEN app.Value1 = 'A' THEN 1
315
                                 ELSE 0
316
                            END A
317
                  FROM      @ABSENCE AS ab
318
                            LEFT JOIN dbo.PCMEPAPPPARAM AS app ON ab.AbsenceType = app.Value2
319
                                                              AND app.Parameter = 'PRPTTMABSENCECAL'
320
                ) AS tbl
321
        GROUP BY tbl.EmployeeID
322

    
323
--SELECT  *
324
--FROM    @dataABSENCE
325

    
326
INSERT  INTO @Attendance
327
        SELECT  emplist.EmployeeID ,
328
                emplist.DateSpecified ,
329
                emplist.StartTime AS WSStartTime ,
330
                emplist.EndTime AS WSEndTime ,
331
                ISNULL(pa19.StartTime, '') AS [19StartTime] ,
332
                ISNULL(pa19.EndTime, '') AS [19EndTime] ,
333
                absence.DayType ,
334
                CASE WHEN ISNULL(pa19.StartTime, '') = ''
335
                          AND ISNULL(pa19.EndTime, '') = ''
336
                          AND absence.DayType IS NULL THEN 'TA' --tidak absen
337
                     WHEN ISNULL(pa19.StartTime, '') = ''
338
                          AND absence.DayType IS NULL THEN 'TAM' --tidak absen masuk
339
                     WHEN ISNULL(pa19.EndTime, '') = ''
340
                          AND absence.DayType IS NULL THEN 'TAP' --tidak absen pulang
341
                     WHEN absence.DayType = 'WDAY' THEN 'ABS' --ada data absence
342
                     ELSE 'H' --hadir
343
                END AS FlagAtt
344
        FROM    @EMPLIST AS emplist
345
                LEFT JOIN dbo.PHRPA0019 pa19 WITH ( NOLOCK ) ON emplist.EmployeeID = pa19.EmployeeID
346
                                                              AND pa19.StartDate = emplist.DateSpecified
347
                LEFT JOIN @ABSENCE absence ON emplist.EmployeeID = absence.EmployeeID
348
                                              AND emplist.DateSpecified = absence.StartDate
349

    
350
--SELECT  *
351
--FROM    @Attendance
352

    
353
INSERT  INTO @dataAttendance
354
        SELECT  EmployeeID ,
355
                DateSpecified ,
356
                WSStartTime ,
357
                WSEndTime ,
358
                [19StartTime] ,
359
                [19EndTime] ,
360
               CASE WHEN FlagAtt = 'TAM' THEN 0
361
					 ELSE
362
						 CASE
363
							 WHEN ISDATE(SUBSTRING([19StartTime], 1, 2) + ':' + SUBSTRING([19StartTime], 3, 2)) = 1
364
								  AND ISDATE(SUBSTRING(WSStartTime, 1, 2) + ':' + SUBSTRING(WSStartTime, 3, 2)) = 1
365
							 THEN
366
								 CONVERT(DECIMAL(18, 0),
367
										 DATEDIFF(MINUTE,
368
												  CAST(SUBSTRING([19StartTime], 1, 2) + ':' + SUBSTRING([19StartTime], 3, 2) AS DATETIME),
369
												  CAST(SUBSTRING(WSStartTime, 1, 2) + ':' + SUBSTRING(WSStartTime, 3, 2) AS DATETIME)))
370
							 ELSE 0
371
						 END
372
				END AS SelisihMasuk,
373

    
374
				CASE WHEN FlagAtt = 'TAP' THEN 0
375
					 ELSE
376
						 CASE
377
							 WHEN ISDATE(SUBSTRING(WSEndTime, 1, 2) + ':' + SUBSTRING(WSEndTime, 3, 2)) = 1
378
								  AND ISDATE(SUBSTRING([19EndTime], 1, 2) + ':' + SUBSTRING([19EndTime], 3, 2)) = 1
379
							 THEN
380
								 CONVERT(DECIMAL(18, 0),
381
										 DATEDIFF(MINUTE,
382
												  CAST(SUBSTRING(WSEndTime, 1, 2) + ':' + SUBSTRING(WSEndTime, 3, 2) AS DATETIME),
383
												  CAST(SUBSTRING([19EndTime], 1, 2) + ':' + SUBSTRING([19EndTime], 3, 2) AS DATETIME)))
384
							 ELSE 0
385
						 END
386
				END AS SelisihPulang,
387
                 CASE WHEN FlagAtt = 'H'
388
					 THEN
389
						 CASE
390
							 WHEN ISDATE(SUBSTRING([19StartTime], 1, 2) + ':' + SUBSTRING([19StartTime], 3, 2)) = 1
391
								 AND ISDATE(SUBSTRING([19EndTime], 1, 2) + ':' + SUBSTRING([19EndTime], 3, 2)) = 1
392
							 THEN
393
								 DATEDIFF(MINUTE,
394
										  CAST(SUBSTRING([19StartTime], 1, 2) + ':' + SUBSTRING([19StartTime], 3, 2) AS DATETIME),
395
										  CAST(SUBSTRING([19EndTime], 1, 2) + ':' + SUBSTRING([19EndTime], 3, 2) AS DATETIME))
396
							 ELSE 0
397
						 END
398
					 ELSE 0
399
				END AS SelisihKerja
400
        FROM    @Attendance
401
        WHERE   FlagAtt NOT IN ( 'ABS', 'TA' )
402

    
403
--SELECT  *
404
--FROM    @dataAttendance
405

    
406
INSERT  INTO @dataNonAttendance
407
        SELECT  EmployeeID ,
408
                SUM(CASE WHEN FlagAtt = 'TA' THEN 1
409
                         ELSE 0
410
                    END) AS 'TA' ,
411
                SUM(CASE WHEN FlagAtt = 'TAM' THEN 1
412
                         ELSE 0
413
                    END) AS 'TAM' ,
414
                SUM(CASE WHEN FlagAtt = 'TAP' THEN 1
415
                         ELSE 0
416
                    END) AS 'TAP'
417
        FROM    @Attendance
418
        WHERE   FlagAtt IN ( 'TA', 'TAM', 'TAP' )
419
        GROUP BY EmployeeID
420

    
421
--SELECT  *
422
--FROM    @dataNonAttendance
423

    
424
INSERT  INTO @dataTelatMasuk
425
        SELECT  EmployeeID ,
426
                SUM(CASE WHEN SelisihMasuk < 0
427
                              AND SelisihMasuk >= -10 THEN 1
428
                         ELSE 0
429
                    END) [Telat<10] ,
430
                SUM(CASE WHEN SelisihMasuk < -10 THEN 1
431
                         ELSE 0
432
                    END) [Telat>10] ,
433
                CAST(( ABS(SUM(CONVERT(INT, SelisihMasuk))) / 60 ) AS VARCHAR(8))
434
                + ':'
435
                + CAST(( ABS(SUM(CONVERT(INT, SelisihMasuk))) % 60 ) AS VARCHAR(2)) AS SelisiTelatMasuk
436
        FROM    @dataAttendance
437
        WHERE   SelisihMasuk < 0
438
        GROUP BY EmployeeID
439

    
440
--SELECT  *
441
--FROM    @dataTelatMasuk
442

    
443
INSERT  INTO @dataMasukAwal
444
        SELECT  EmployeeID ,
445
                SUM(CASE WHEN SelisihMasuk > 0 THEN 1
446
                         ELSE 0
447
                    END) [MasukAwal] ,
448
                CAST(( ABS(SUM(CONVERT(INT, SelisihMasuk))) / 60 ) AS VARCHAR(8))
449
                + ':'
450
                + CAST(( ABS(SUM(CONVERT(INT, SelisihMasuk))) % 60 ) AS VARCHAR(2)) AS SelisihMasuk
451
        FROM    @dataAttendance
452
        WHERE   SelisihMasuk > 0
453
        GROUP BY EmployeeID
454

    
455
--SELECT  *
456
--FROM    @dataMasukAwal
457

    
458
INSERT  INTO @dataPulangAwal
459
        SELECT  EmployeeID ,
460
                SUM(CASE WHEN SelisihPulang < 0 THEN 1
461
                         ELSE 0
462
                    END) [PulangAwal] ,
463
                CAST(( ABS(SUM(CONVERT(INT, SelisihPulang))) / 60 ) AS VARCHAR(8))
464
                + ':'
465
                + CAST(( ABS(SUM(CONVERT(INT, SelisihPulang))) % 60 ) AS VARCHAR(2)) AS SelisihPulang
466
        FROM    @dataAttendance
467
        WHERE   SelisihPulang < 0
468
        GROUP BY EmployeeID
469

    
470
--SELECT  *
471
--FROM    @dataPulangAwal
472

    
473
INSERT  INTO @dataDurasiKerja
474
        SELECT  EmployeeID ,
475
                CAST(( FLOOR(AVG(CONVERT(INT, SelisihKerja))) / 60 ) AS VARCHAR(8))
476
                + ':'
477
                + CAST(( FLOOR(AVG(CONVERT(INT, SelisihKerja))) % 60 ) AS VARCHAR(2)) AS AVGKerja ,
478
                CAST(( ABS(SUM(CONVERT(INT, SelisihKerja))) / 60 ) AS VARCHAR(8))
479
                + ':'
480
                + CAST(( ABS(SUM(CONVERT(INT, SelisihKerja))) % 60 ) AS VARCHAR(2)) AS SelisihKerja
481
        FROM    @dataAttendance
482
        WHERE   SelisihKerja <> 0
483
        GROUP BY EmployeeID
484

    
485
--SELECT  *
486
--FROM    @dataDurasiKerja
487

    
488
SELECT DISTINCT
489
        UPPER(dbo.fn_formatdatetime_indonesia(@TMPeriodStartDate, 'MMMM yyyy')) AS Bulan ,
490
        emp.EmployeeID ,
491
        emp.FullName ,
492
        --ISNULL(dataAbs.C, '0') AS Cuti ,
493
        ISNULL(sc.TotalCuti, '0') AS Cuti ,
494
		sc.TotalCuti,
495
        --ISNULL(dataAbs.I, '0') AS IjinSakit ,
496
        ISNULL(sumsak.Sum_IjinSakit, '0') AS IjinSakit ,
497
        CONVERT(INT, ISNULL(dataNA.TA, '0')) + CONVERT(INT, ISNULL(dataAbs.A,
498
                                                              '0')) AS Alpha ,
499
        ISNULL(dataTelat.[Telat<10], '0') AS TelatKurang10 ,
500
        ISNULL(dataTelat.[Telat>10], '0') AS TelatLebih10 ,
501
        ISNULL(dataTelat.SelisihTelat, '0') AS SelisihTelat ,
502
        ISNULL(dataMA.MasukAwal, '0') AS MasukAwal ,
503
        ISNULL(dataMA.SelisihMasuk, '0') AS SelisihMasuk ,
504
        ISNULL(dataPA.PulangAwal, '0') AS PulangAwal ,
505
        ISNULL(dataPA.SelisihPulang, '0') AS SelisihPulang ,
506
        ISNULL(dataNA.TA, '0') AS TA ,
507
        ISNULL(dataNA.TAM, '0') AS TAM ,
508
        ISNULL(dataNA.TAP, '0') AS TAP ,
509
        ISNULL(dataDK.AVGKerja, '0') AS AVGKerja ,
510
        ISNULL(dataDK.SelisihKerja, '0') AS SelisihKerja
511
FROM    @EMP emp
512
        LEFT JOIN @dataABSENCE dataAbs ON emp.EmployeeID = dataAbs.EmployeeID
513
        LEFT JOIN @dataTelatMasuk dataTelat ON emp.EmployeeID = dataTelat.EmployeeID
514
        LEFT JOIN @dataMasukAwal dataMA ON emp.EmployeeID = dataMA.EmployeeID
515
        LEFT JOIN @dataPulangAwal dataPA ON emp.EmployeeID = dataPA.EmployeeID
516
        LEFT JOIN @dataNonAttendance dataNA ON emp.EmployeeID = dataNA.EmployeeID
517
        LEFT JOIN @dataDurasiKerja dataDK ON emp.EmployeeID = dataDK.EmployeeID
518
        LEFT JOIN @SUM_ABSENCE sumcu ON emp.EmployeeID = sumcu.EmployeeID
519
        LEFT JOIN @SUM_IJIN_SAKIT sumsak ON emp.EmployeeID = sumsak.EmployeeID
520
		LEFT JOIN @Sum_Cuti sc ON emp.EmployeeID = sc.EmployeeID
521

    
522
--WHERE emp.EmployeeID ='10000032'
523
ORDER BY emp.EmployeeID
(3-3/3)