Advertisement
Fhernd

Receta_TSQL-3.1_Ej_2.sql

Jul 20th, 2015
1,279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.53 KB | None | 0 0
  1. -- OrtizOL - xCSw - http://ortizol.blogspot.com
  2.  
  3. SELECT c.CustomerID,
  4.     SalesPersonPhone = spp.PhoneNumber,
  5.     CustomerPhone = pp.PhoneNumber,
  6.     PhoneNumber = COALESCE(pp.PhoneNumber, spp.PhoneNumber, 'SIN TELΓ‰FONO')
  7. FROM Sales.Customer c
  8.     LEFT OUTER JOIN Sales.Store s
  9.         ON c.StoreID = s.BusinessEntityID
  10.     LEFT OUTER JOIN Person.PersonPhone spp
  11.         ON s.SalesPersonID = spp.BusinessEntityID
  12.     LEFT OUTER JOIN Person.PersonPhone pp
  13.         ON c.CustomerID = pp.BusinessEntityID
  14. ORDER BY CustomerID;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement