Bug #2388 » queryCRIMFIATT.txt
| 1 |
|
|---|---|
| 2 |
select landscape,workschedule_type,datespecified, day_type into #cal from hr_tm_workschedule_calender where datespecified >= '20230901' and day_type = 'OFF' |
| 3 |
select landscape,emp_id,start_date,attendance_type into #md19 from hr_md_emp_md0019 where start_date >= '20230901' and attendance_type = 'P' |
| 4 |
select * into #md25 from hr_md_emp_md0025 where start_date >= '20230901' |
| 5 |
|
| 6 |
--select * from hr_md_emp_md0025 where emp_id ='20230211' |
| 7 |
--select * from #cal |
| 8 |
--select * from #md19 |
| 9 |
|
| 10 |
select DISTINCT |
| 11 |
md19.emp_id, |
| 12 |
cal.datespecified, |
| 13 |
cal.workschedule_type, |
| 14 |
cal.day_type, |
| 15 |
md19.attendance_type |
| 16 |
into #tempA from #cal cal |
| 17 |
inner join #md19 md19 ON cal.datespecified = md19.start_date |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
select DISTINCT md25.emp_id,tempA.datespecified,tempA.workschedule_type,tempA.day_type,tempA.attendance_type |
| 22 |
into #tempFinal |
| 23 |
from #md25 md25 |
| 24 |
left join #tempA tempA on md25.emp_id = tempA.emp_id and md25.ws_type = tempA.workschedule_type |
| 25 |
where md25.start_date <= tempA.datespecified and end_date >= tempA.datespecified |
| 26 |
|
| 27 |
--select * from #tempFinal |
| 28 |
|
| 29 |
UPDATE |
| 30 |
hr_md_emp_md0019 |
| 31 |
SET |
| 32 |
attendance_type = 'P1' |
| 33 |
FROM |
| 34 |
hr_md_emp_md0019 U19 |
| 35 |
inner join #tempFinal final on U19.emp_id = final.emp_id and U19.start_date = final.datespecified |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
drop table #tempA |
| 40 |
drop table #tempFinal |
| 41 |
drop table #md25 |
| 42 |
drop table #cal |
| 43 |
drop table #md19 |
| 44 |
|
| 45 |
|