Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. use NORTHWND
  2.  
  3. --unit price
  4. --quantity
  5. --ship country
  6. --category name
  7.  
  8. --wykres sumy sprzedazy w podziale kategorii i kraj wysylki
  9. create view
  10. wykres as
  11. select sum(od.UnitPrice*quantity)as 'suma sprzedazy', categoryname, shipcountry
  12. from orders o join [Order Details] od on o.OrderID = od. OrderID
  13. join products p on p.ProductID = od.ProductID
  14. join Categories c on c.CategoryID = p.CategoryID
  15.  
  16. group by CategoryName, ShipCountry
  17.  
  18. select * from wykres
  19. -- wartosc zamowien skladanych z polski w poszczegolnych dniach tygonida
  20. create view
  21. wykres3 as
  22.  
  23. select country, DATENAME(weekday, orderdate) as 'dzien tygodnia',sum(od.UnitPrice*quantity)as 'suma sprzedazy'
  24. from orders o join [Order Details] od on o.OrderID = od. OrderID
  25. join Customers c on c.CustomerID = o.CustomerID
  26. where country = 'POLAND'
  27. group by country, DATENAME(weekday, orderdate)
  28.  
  29. select * from wykres3
  30.  
  31.  
  32. -- liczba zamowien z usa w poszczegolnych miesiacach i latach na roznych poziomach szczegolowosci
  33.  
  34. select shipcountry, year(orderdate) as'rok', month(orderdate) as 'miesiac', sum(od.UnitPrice*quantity) as 'suma sprzedazy'
  35. from orders o join [Order Details] od on o.OrderID = od.OrderID
  36. group by ShipCountry, year(orderdate), month(orderdate)
  37. -- trzeba zrobic groupingi ale mi sie nie chce 😞
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement