Is there a way to give a subquery an alias in Oracle 11g SQL?

Posted by Matt Pascoe on Stack Overflow See other posts from Stack Overflow or by Matt Pascoe
Published on 2010-06-16T23:35:44Z Indexed on 2010/06/16 23:42 UTC
Read the original article Hit count: 229

Filed under:
|
|
|
|

Is there a way to give a subquery in Oracle 11g an alias like:

select * 
from
    (select client_ref_id, request from some_table where message_type = 1) abc,
    (select client_ref_id, response  from some_table where message_type = 2) defg
where
    abc.client_ref_id = def.client_ref_id;

Otherwise is there a way to join the two subqueries based on the client_ref_id. I realize there is a self join, but on the database I am running on a self join can take up to 5 min to complete (there is some extra logic in the actual query I am running but I have determined the self join is what is causing the issue). The individual subqueries only take a few seconds to complete by them selves. The self join query looks something like:

select st.request, st1.request
from
    some_table st, some_table st1
where 
    st.client_ref_id = st1.client_ref_id;

© Stack Overflow or respective owner

Related posts about sql

Related posts about subquery