Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- OrtizOL - xCSw - http://ortizol.blogspot.com
- SELECT c.CustomerID,
- SalesPersonPhone = spp.PhoneNumber,
- CustomerPhone = pp.PhoneNumber,
- PhoneNumber = COALESCE(pp.PhoneNumber, spp.PhoneNumber, 'SIN TELÉFONO')
- FROM Sales.Customer c
- LEFT OUTER JOIN Sales.Store s
- ON c.StoreID = s.BusinessEntityID
- LEFT OUTER JOIN Person.PersonPhone spp
- ON s.SalesPersonID = spp.BusinessEntityID
- LEFT OUTER JOIN Person.PersonPhone pp
- ON c.CustomerID = pp.BusinessEntityID
- ORDER BY CustomerID;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement