Skip to content
Tako Lee edited this page Mar 5, 2014 · 24 revisions
  • Join clause at the same level with from clause

    • Do not Align first table source with following table source

      SELECT p.Name, sod.SalesOrderID
      FROM Production.Product AS p
      LEFT OUTER JOIN Sales.SalesOrderDetail AS sod
      ON p.ProductID = sod.ProductID
    • Align first table source with following table source

      SELECT p.Name, sod.SalesOrderID
      FROM            Production.Product AS p
      LEFT OUTER JOIN Sales.SalesOrderDetail AS sod
      ON p.ProductID = sod.ProductID
    • Table in join clause at new line

      SELECT p.Name, sod.SalesOrderID
      FROM            
          Production.Product AS p
      LEFT OUTER JOIN 
          Sales.SalesOrderDetail AS sod
      ON p.ProductID = sod.ProductID
  • Join clause at the sub level with from clause

    • Join table not in new line

      SELECT p.Name, sod.SalesOrderID
      FROM Production.Product AS p
           LEFT OUTER JOIN Sales.SalesOrderDetail AS sod
           ON p.ProductID = sod.ProductID
    • Join table in new line

      SELECT p.Name, sod.SalesOrderID
      FROM Production.Product AS p
           LEFT OUTER JOIN 
             Sales.SalesOrderDetail AS sod ON p.ProductID = sod.ProductID
  • ON condition

  • On the same line with table source

    SELECT p.Name, sod.SalesOrderID
    FROM 
      Production.Product AS p
    LEFT OUTER JOIN Sales.SalesOrderDetail AS sod ON p.ProductID = sod.ProductID
  • On a new line

    • Align with table source

      SELECT p.Name, sod.SalesOrderID
      FROM 
        Production.Product AS p
      LEFT OUTER JOIN Sales.SalesOrderDetail AS sod
                      ON p.ProductID = sod.ProductID
    • Align with JOIN keyword

      SELECT p.Name, sod.SalesOrderID
      FROM 
        Production.Product AS p
      LEFT OUTER JOIN Sales.SalesOrderDetail AS sod
                   ON p.ProductID = sod.ProductID

Clone this wiki locally