简体   繁体   中英

Convert OUTER APPLY To Oracle 11g statement

I have the following TSQL,

select 2*EC.Total C1, T1.C2, EC.Total
FROM MyTable1 T1 
OUTER APPLY (select COUNT(*) AS Total from MyTable2 T2 WHERE T1.SomeColumn=T2.SomeColumn ) EC
ORDER BY EC.Total desc

I need to convert this to Oracle 11g. I tried lateral but not supported.

You don't really need a lateral join there:

select 2*EC.Total C1, T1.C2, EC.Total
FROM MyTable1 T1 
  LEFT JOIN (
    select m2.somecolumn, COUNT(*) AS Total 
    from MyTable2 m2
    group by m2.somecolumn
  ) ec ON t1.somecolumn = ec.somecolumn
ORDER BY EC.Total desc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM