0
我想加入三个表,我想要获取装运ID,其中表2中的时间(装运的日期和时间)应该小于表3。 CHANGE_DATE的格式为在oracle中检查两个时间戳sql
select shipment_id from table1
left join table2 on table1.shipment_id=table2.shipment_id
left join table3 on table2.shipment_id=table3.shipment_id and table2.Code=table3.Code
where table2.change_date<table3.change_date
数据按下面
表1
shipment_id
123456
表2
shipment_id--------------Change_Date-------------------------Code
123456------19-JAN-17 09.54.07.000000 AM----------------32
123456------19-JAN-17 10.54.07.000000 PM----------------51
表3
shipment_id--------------Change_Date-------------------------Code
123456------19-JAN-17 12.54.07.000000 PM----------------32
123456------19-JAN-17 07.54.07.000000 AM----------------32
123456------20-JAN-17 09.54.10.000000 AM----------------32
所以我需要的输出作为
shipemnt_id-------------Change_Date
123456--------19-JAN-17 12.54.07.000000 PM
123456--------20-JAN-17 09.54.10.000000 AM
请帮助