0

I'm relatively new to SQL and a complete beginner with Oracle, and having difficulty understanding the (+) syntax. Consider the following query:

SELECT *
FROM   CustomerShip,
    (SELECT DISTINCT b.ShipSeq AS shipSeq
     FROM   Orders a,
            CustomerShip b
     WHERE  a.OrderId IN (SELECT OrderId
                          FROM   Orders
                          WHERE  CustomerId = @CustomerId
                          AND    OrderType <> 'A')
     AND    b.CustomerId = @CustomerId
     AND    b.ShipSeq = a.CustShip
     AND    OrderStatus <> 'C'
     GROUP BY b.ShipSeq) i
WHERE  CustomerId = @CustomerId
AND    (Address NOT LIKE '%RETAIL%STORE%')
AND    ShipSeq = i.ShipSeq(+)
ORDER BY ShipTo DESC, OrderDate DESC;

So I gather the (+) in Oracle is an outer join, but I'm confused what is is joining on? The result of the inner query i. I need to rewrite this query for MSSQL and not sure what that would look like?

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
PixelPaul
  • 2,357
  • 4
  • 31
  • 53

1 Answers1

1

The columns that are joined on are just before the plus sign.

 ... FROM CustomerShip s LEFT OUTER JOIN (....) i ON s.ShipSeq = i.ShipSeq
SAS
  • 3,755
  • 2
  • 26
  • 46