我有一个非常简单的问题:oracle是否允许在单个sql语句中使用多个"WITH AS".
例:
WITH abc AS( select ......)
WITH XYZ AS(select ....) /*This one uses "abc" multiple times*/
Select .... /*using XYZ multiple times*/
Run Code Online (Sandbox Code Playgroud)
我可以通过多次重复相同的查询来使查询工作,但不想这样做,并利用"WITH AS".这似乎是一个简单的要求,但oracle不允许我:
ORA-00928:缺少SELECT关键字
Dee*_*kha 158
你可以这样做:
WITH abc AS( select
FROM ...)
, XYZ AS(select
From abc ....) /*This one uses "abc" multiple times*/
Select
From XYZ.... /*using abc, XYZ multiple times*/
Run Code Online (Sandbox Code Playgroud)
小智 24
正确的语法是 -
with t1
as
(select * from tab1
where conditions...
),
t2
as
(select * from tab2
where conditions...
(you can access columns of t1 here as well)
)
select * from t1, t2
where t1.col1=t2.col2;
Run Code Online (Sandbox Code Playgroud)
是的你可以...
WITH SET1 AS (SELECT SYSDATE FROM DUAL), -- SET1 initialised
SET2 AS (SELECT * FROM SET1) -- SET1 accessed
SELECT * FROM SET2; -- SET2 projected
10/29/2013 10:43:26 AM
Run Code Online (Sandbox Code Playgroud)
按照在公用表表达式中初始化它的顺序
| 归档时间: |
|
| 查看次数: |
137606 次 |
| 最近记录: |