-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConditional_OT_Remove_and_Update.txt
More file actions
31 lines (21 loc) · 1.32 KB
/
Conditional_OT_Remove_and_Update.txt
File metadata and controls
31 lines (21 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- select data using another table
/* like
Which card no get OT On the 23rd, they will not give the OT on the 27th.
*/
select * from tb_data_master where cardno=(
select cardno from new_table_s where cardno=(
select cardno from tb_personal_info where OTORG='Y' and active=0 and tb_personal_info.cardno=new_table_s.cardno
)
and finmonth='July' and finyear=2019 and otmin=0 and PDATE = TO_DATE('07/13/2019 00:00:00', 'MM/DD/YYYY HH24:MI:SS')
and tb_data_master.cardno=new_table_s.cardno
)and finmonth='July' and finyear=2019 and PDATE = TO_DATE('07/27/2019 00:00:00', 'MM/DD/YYYY HH24:MI:SS')
create table new_table_f as ( select * from tb_data_master where cardno=(
select cardno from new_table_s where cardno=(
select cardno from tb_personal_info where OTORG='Y' and active=0 and tb_personal_info.cardno=new_table_s.cardno
)
and finmonth='July' and finyear=2019 and otmin=0 and PDATE = TO_DATE('07/24/2019 00:00:00', 'MM/DD/YYYY HH24:MI:SS')
and tb_data_master.cardno=new_table_s.cardno
)and finmonth='July' and finyear=2019 and PDATE = TO_DATE('07/23/2019 00:00:00', 'MM/DD/YYYY HH24:MI:SS')
);
create table new_table_s as ( select * from tb_data_master where FINYEAR=2019 and FINMONTH='July' AND PDATE = TO_DATE('07/27/2019 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
DROP TABLE NEW_TABLE_f