;在Oracle中使用tablename作为(..)等效项

时间:2016-11-02 13:35:29

标签: sql oracle common-table-expression

我是Oracle新手,我正在尝试复制一种非常有用的查询类型,我总是在SQL Server中使用它。

我正在尝试在Oracle中找到此查询的等效项

; With tablename as (
Select 
Column1 ,
Column2
From table1
) 
, with tablename2 as (
Select 
column3,
Column4
)
Select 
Column 2 ,
column 4
from Tablename t1
left outer join tablename t2
on t1.column1 = t2.column3

1 个答案:

答案 0 :(得分:2)

您有一些错误(列名称中的空格,缺少FROM,...)。 这应该有效:

WITH tablename AS (SELECT Column1, Column2 FROM table1),
     tablename2 AS (SELECT column3, Column4 FROM table2)
SELECT Column2, column4
  FROM Tablename t1 LEFT OUTER JOIN tablename t2 ON t1.column1 = t2.column3