luisnaranjo733

lab1q4

Oct 14th, 2015
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.63 KB | None | 0 0
  1. /* What is the average freight charge for all orders shipped to France and United States beginning in December 1996? */
  2.  
  3. /* Attempt #1: http://pastebin.com/8RwHP6Et */
  4.  
  5. /* All orders shipped to FR and US since 12/1/1996 */
  6.  
  7. SELECT SOH.ShipDate, SOH.Freight, ST.CountryRegionCode FROM [Sales].[SalesOrderHeader] SOH
  8. JOIN [Person].[Address] Addr ON SOH.ShipToAddressID=Addr.AddressID
  9. JOIN [Person].[StateProvince] StateProvince ON Addr.StateProvinceID = StateProvince.StateProvinceID
  10. JOIN [Sales].[SalesTerritory] ST ON StateProvince.TerritoryID = ST.TerritoryID
  11. WHERE ST.CountryRegionCode IN ('US', 'FR') AND SOH.ShipDate > '12/1/1996'
Advertisement
Add Comment
Please, Sign In to add comment