复杂SQL学习

来源:互联网 发布:p2p摄像头软件下载 编辑:程序博客网 时间:2024/06/05 20:05
select * from (select d.*,  rownum r from (select a.req_id req_id,a.imcc_order_id imcc_order_id,
to_char(a.input_date,'yyyy-MM-dd') input_date,
a.title title, a.approve_dept approve_dept, a.approve_advice approve_advice,
to_char(a.approve_time,'yyyy-MM-dd') approve_time,
to_char(a.resolve_time,'yyyy-MM-dd') resolve_time,
to_char(a.out_time,'yyyy-MM-dd') out_time,a.outFlag outFlag,
(select org_name from o_org where org_no= b.org_no) req_orgNo,
b.severity severity,
b.second_category second_category,
b.event_original event_original,
c.system_name system_name 
from WEB_REQUIREMENT a left join work_order b
on a.imcc_order_id = b.imcc_order_id 
left join SER_SYSTEM_INFO c 
on b.app_sys = c.system_info_id
where a.resolve_time is null and a.input_date is not null 
order by input_date desc) d)  where r > 1 and r < 2