简体   繁体   中英

What does this oracle SQL syntax mean?

I'm trying to get Power BI to import some oracle SQL data, but it seems I have to modernize some of it's syntax. I can't seem to figure out what this means:

(
    (  SELECT 
           t1.column1
       FROM 
           table1 t1
       WHERE 
           t1.column3 = something
    )
    +
    (  SELECT 
           t2.column2 
       FROM 
           table2 t2
       WHERE 
           t2.column3 = somethingelse
    )
) AS name

It's the +-sign in the middle that throws me. I've already learned that there's an old syntax for OUTER JOIN that uses a WHERE-clause with (+)-symbol to denote left/right, but this doesn't follow the syntax as there's no WHERE-clause. Maybe it's just some regular SQL syntax that I've never seen before. Please enlighten me?

As @astentx stated in his comment , (SELECT... FROM...) is a scalar sub-query and the + operator is adding the numeric values that are returned from the sub-queries.

You could equally have written it as:

( SELECT t1.column1 + 
  FROM   table1 t1
         CROSS JOIN t2.column2 
  WHERE  t1.column3 = something
  AND    t2.column3 = somethingelse
) AS name

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