Facebook
From Aqua Pudu, 6 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 160
  1. use AdventureWorks2014
  2.  
  3. select * from production.TransactionHistory
  4. where ActualCost >0
  5. order by ProductID desc
  6.  
  7. select TOP 3 LocationID, count(*) as liczba
  8. from Production.ProductInventory
  9. group by LocationID
  10. order by liczba desc
  11.  
  12. select l.name, pi.quantity, p.listprice, p.color
  13. from production.location as l
  14. join production.ProductInventory as pi
  15. on pi.locationID = l.locationID
  16. Join Production.Product as p
  17. on p.ProductID = pi.ProductID
  18.  
  19. select sm.Name, count(*)
  20. from sales.SalesOrderHeader as soh
  21. join purchasing.ShipMethod as sm
  22. on sm.ShipMethodID= soh.ShipMethodID
  23. group by sm.Name
  24.  
  25. select p.name as nazwaproduktu, listprice, l.name
  26. from production.ProductInventory as pinv
  27. join production.location as l on l.locationID = pinv.locationid
  28. join production.product as p on p.productId=pinv.productid
  29.  
  30.  
  31. select sm.name, count(*) as liczba
  32. from sales.SalesOrderHeader as soh
  33. join Purchasing.ShipMethod as sm on sm.ShipMethodID = soh.ShipMethodID
  34. group by sm.name
  35. order by liczba desc
  36.  
  37. select * from Production.ProductInventory
  38. select * from Production.Product
  39.  
  40.  
  41. select * from sales.SalesOrderHeader
  42. select * from Purchasing.ShipMethod
  43.  
  44. select sm.name, count (*) as liczba
  45. from sales.SalesOrderHeader as soh
  46. join Purchasing.ShipMethod as SM on sm.ShipMethodID = soh.ShipMethodID
  47. group by sm.Name