SHARE
TWEET

Untitled

selvalives Nov 19th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select * from customers;
  2.  
  3. select
  4. country,count(*) as total
  5. from customers group by country
  6. order by total desc;
  7.  
  8. select * from employees;
  9.  
  10. select title,count(*) as total
  11. from employees
  12. group by title
  13. order by total desc;
  14.  
  15. select * from products;
  16.  
  17. select categoryname,count(*) as total
  18. from products p join Categories c
  19. on p.CategoryID=c.CategoryID
  20. group by categoryname
  21. order by total desc;
  22.  
  23. select * from orders;
  24.  
  25. select
  26. year(orderdate) as yearr,
  27. month(orderdate) as monthh,
  28. count(*)as totalorders,
  29. sum(unitprice*quantity) as totalsales
  30. from orders o
  31. join orderdetails od
  32. on o.OrderID=od.OrderID
  33. group by
  34. year(orderdate),
  35. month(orderdate)
  36. order by yearr asc,monthh asc
  37.  
  38.  
  39. select
  40. productname,
  41. year(orderdate) as yearr,
  42. month(orderdate) as monthh,
  43. count(*)as totalorders,
  44. sum(od.unitprice*quantity) as totalsales
  45. from orders o
  46. join orderdetails od
  47. on o.OrderID=od.OrderID
  48. join products p
  49. on od.ProductID=p.ProductID
  50. group by
  51. productname,
  52. year(orderdate),
  53. month(orderdate)
  54. order by productname asc, yearr asc,monthh asc
  55.  
  56. select
  57. companyname,
  58. year(orderdate) as yearr,
  59. month(orderdate) as monthh,
  60. count(*)as totalorders,
  61. sum(unitprice*quantity) as totalsales
  62. from orders o
  63. join orderdetails od
  64. on o.OrderID=od.OrderID
  65. join customers c
  66. on o.CustomerID=c.CustomerID
  67. group by
  68. companyname,
  69. year(orderdate),
  70. month(orderdate)
  71. order by companyname,yearr asc,monthh asc
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