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

后端 未结 3 1547
春和景丽
春和景丽 2021-02-07 04:44

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,
            


        
3条回答
  •  抹茶落季
    2021-02-07 05:39

    You can give a query a name or alias with CTE’s (Common Table Expressions) aka WITH clause aka by Oracle as Subquery Factoring:

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

提交回复
热议问题