Oracle With As

来源:互联网 发布:Java string转化为int 编辑:程序博客网 时间:2024/06/03 21:36

长期不写SQL后经常容易忘记,免得再次Baidu,写个简单例子方便查阅。

with

T1 as (select A from Table1),

T2 as (select A from Table2 where not exists (select A from T1 where rownum=1))

select * from T1

union all

select * from T2

union all

select 'no records' from dual

       where not exists (select A from T1 where rownum=1)

       and not exists (select A from T2 where rownum=1);

 

0 0
原创粉丝点击