Skip to Main Content

With alias in another with?

Marco SilvaAug 18 2015 — edited Aug 19 2015

Hey guys, can someone help me?

I need to run an extremely heavy Query and use its results in another Query. For this, I am putting it in a subquery using the clause "with". But I also need to use this result in another subquery "with". How can I do this without losing performance?


Example:


With dummy as (select id, count(*) as qtd from dual group by id),

        dummy_dummy as (select dual.id, count(dummy.*) as qtd from dual, dummy where dual.id = dummy.id group by dual.id)

select dummy.qtd, dummy_dummy.qtd

from dummy, dummy_dummy

where dummy.id = dummy_dummy.id(+)


Thanks.

Comments
Post Details
Added on Aug 18 2015
4 comments
147 views