- 论坛徽章:
- 0
|
老是看见这类查询语句的写法,但就是不明白,谁能给加个说明呢?非常感谢!
- select *
- from (
- select t1.trans_id,
- decode( r, 1, 'C1', 2, 'C2', 3, 'C3' ) cname,
- decode( r, 1, to_char(t1.c1,'dd-mon-yyyy hh24:mi:ss'),
- 2, to_char(t1.c2),
- 3, t1.c3) v1,
- decode( r, 1, to_char(t2.c1,'dd-mon-yyyy hh24:mi:ss'),
- 2, to_char(t2.c2),
- 3, t2.c3) v2
- from
- (select rownum rr, trans.* from trans where trans_id = :bv ) t1,
- (select rownum rr, trans_tmp.* from trans_tmp where trans_id = :bv) t2,
- (select rownum r from all_objects where rownum <= 3 ) t3,
- (select rownum rr from dual) t4
- where t1.rr(+) = t4.rr
- and t2.rr(+) = t4.rr
- )
- where v1 <>; v2
- or (v1 is null and v2 is not null)
- or (v1 is not null and v2 is null)
- /
复制代码 |
|