2013-08-02 36 views
3

我可以做這樣的事情:SQL與子句中的條款

with t as 
    (
     with tt as 
      ( 
       select * from table 
      ) 
     SELECT * FROM tt 
    ) 
select * from t 

我願與第&比內輸出功率進行一些邏輯再次做外的輸出與從句中某些操作。

任何幫助將不勝感激...
感謝

注: - 它只是一些簡單的查詢,將解決我的實際查詢,已嵌套條款我的問題

回答

13

你可以做些什麼像這樣:

with t as 
(
    select * from table 
), 
tt as 
( 
    select * from t 
) 
select * from tt 
+0

你是否認爲'select * from table' in 7th line? – objectWithoutClass

+0

大聲笑在我.....赫赫看到我的編輯,感謝您指出。 –

+0

這是做到這一點的方法!謝謝 –

4

不,你不能 CTE(公共表表達式),但你可以他們:

with t as 
(
    select * from table 
), 
tt as 
( 
    select * from t 
) 
SELECT * FROM tt 
+0

在第一個條款我可以寫一些選擇查詢? – objectWithoutClass

+0

@objectWithoutClass:**確定!**請繼續嘗試! –