SHARE
TWEET

Untitled

a guest Nov 15th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. USE Northwind
  2.  
  3. -- ćwiczenie 1
  4.  
  5. SELECT OrderID, SUM(UnitPrice*Quantity) FROM [ORDER Details] GROUP BY OrderID ORDER BY SUM(UnitPrice*Quantity)
  6.  
  7. SELECT top 10 OrderID, SUM(UnitPrice*Quantity) FROM [ORDER Details] GROUP BY OrderID ORDER BY SUM(UnitPrice*Quantity)
  8.  
  9. -- ćwiczenie 2
  10.  
  11. SELECT ProductID, SUM(Quantity) FROM [ORDER Details] WHERE ProductID < 3 GROUP BY ProductID
  12.  
  13. SELECT ProductID, SUM(Quantity) FROM [ORDER Details] GROUP BY ProductID
  14.  
  15. SELECT OrderID, SUM(Quantity*UnitPrice), SUM(Quantity) FROM [ORDER Details] GROUP BY OrderID HAVING SUM(Quantity) > 250
  16.  
  17. -- ćwiczenie 3
  18.  
  19. SELECT EmployeeID, COUNT(*) FROM Orders GROUP BY EmployeeID
  20.  
  21. SELECT ShipVia, SUM(Freight) AS "Oplata za przesylke" FROM Orders GROUP BY ShipVia
  22.  
  23. SELECT ShipVia, SUM(Freight) AS "Oplata za przesylke"
  24. FROM Orders
  25. WHERE  YEAR(ShippedDate)=1996 OR YEAR(ShippedDate)=1997
  26. GROUP BY ShipVia
  27.  
  28. SELECT EmployeeID, YEAR(OrderDate) AS "Year", MONTH(OrderDate) AS "Month", COUNT(*) AS "number"
  29. FROM Orders
  30. GROUP BY EmployeeID, YEAR(OrderDate), MONTH(OrderDate)
  31. ORDER BY EmployeeID, YEAR(OrderDate), MONTH(OrderDate)
  32.  
  33. SELECT CategoryID, MAX(UnitPrice) AS "Max", MIN(UnitPrice) AS "Min"
  34. FROM Products
  35. GROUP BY CategoryID
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top