Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql with clause within a with clause

can i do something like this :

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

i willing to perform some logic on output of inner with clause & than again do some operations on output of the outer with clause.

any help will be appreciated ...
Thanks

note :- its just some simplified query that will resolve my problem in my actual query, which have nested with clause

like image 989
objectWithoutClass Avatar asked Aug 02 '13 07:08

objectWithoutClass


1 Answers

You can do something like this:

with t as 
(
    select * from table
),
tt as
( 
     select * from t
)
select * from tt 
like image 176
Giannis Paraskevopoulos Avatar answered Sep 22 '22 08:09

Giannis Paraskevopoulos