Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. ---------------------------------------- Question 16 Query ----------------------------------------
  2. SELECT employees.first_name, employees.last_name, COUNT(orders.customer_id) FROM employees INNER JOIN orders ON employees.employee_id=orders.employee_id GROUP BY employees.first_name, employees.last_name HAVING COUNT(DISTINCT orders.customer_id) > 50;
  3. ---------------------------------------- Question 16 Results --------------------------------------
  4. first_name | last_name | count
  5. ------------+-----------+-------
  6. Andrew | Fuller | 96
  7. Janet | Leverling | 127
  8. Laura | Callahan | 104
  9. Margaret | Peacock | 156
  10. Nancy | Davolio | 123
  11. (5 rows)
  12. ---------------------------------------- Question 17 Query ----------------------------------------
  13. SELECT product_name FROM products WHERE unit_price < (SELECT AVG(unit_price) FROM products);
  14. ---------------------------------------- Question 17 Results --------------------------------------
  15. product_name
  16. ----------------------------------
  17. Chai
  18. Chang
  19. Aniseed Syrup
  20. Chef Anton's Cajun Seasoning
  21. Chef Anton's Gumbo Mix
  22. Grandma's Boysenberry Spread
  23. Queso Cabrales
  24. Konbu
  25. Tofu
  26. Genen Shouyu
  27. Geitost
  28. Pavlova
  29. Teatime Chocolate Biscuits
  30. Sir Rodney's Scones
  31. Gustaf's Knäckebröd
  32. Tunnbröd
  33. Guaraná Fantástica
  34. NuNuCa Nuß-Nougat-Creme
  35. Nord-Ost Matjeshering
  36. Gorgonzola Telino
  37. Sasquatch Ale
  38. Steeleye Stout
  39. Inlagd Sill
  40. Gravad lax
  41. Chartreuse verte
  42. Boston Crab Meat
  43. Jack's New England Clam Chowder
  44. Singaporean Hokkien Fried Mee
  45. Gula Malacca
  46. Rogede sild
  47. Spegesild
  48. Zaanse koeken
  49. Chocolade
  50. Maxilaku
  51. Valkoinen suklaa
  52. Filo Mix
  53. Tourtière
  54. Pâté chinois
  55. Ravioli Angelo
  56. Escargots de Bourgogne
  57. Sirop d'érable
  58. Louisiana Fiery Hot Pepper Sauce
  59. Louisiana Hot Spiced Okra
  60. Laughing Lumberjack Lager
  61. Scottish Longbreads
  62. Outback Lager
  63. Flotemysost
  64. Röd Kaviar
  65. Longlife Tofu
  66. Rhönbräu Klosterbier
  67. Lakkalikööri
  68. Original Frankfurter grüne Soße
  69. (52 rows)
  70. ---------------------------------------- Question 18 Query ----------------------------------------
  71. SELECT COUNT(DISTINCT orders.employee_id) FROM employees FULL JOIN orders ON employees.employee_id=orders.employee_id WHERE ship_city=city AND ship_address != address;
  72. ---------------------------------------- Question 18 Results --------------------------------------
  73. count
  74. -------
  75. 6
  76. (1 row)
  77. ---------------------------------------- Question 19 Query ----------------------------------------
  78. SELECT first_name, last_name, COUNT(DISTINCT customer_id) AS unique_clients, COUNT(*) AS order_count FROM employees FULL JOIN orders ON employees.employee_id=orders.employee_id WHERE order_date >= '1998-01-01'::DATE AND order_date <= '1998-12-31'::DATE GROUP BY employees.first_name, employees.last_name;
  79. ---------------------------------------- Question 19 Results --------------------------------------
  80. first_name | last_name | unique_clients | order_count
  81. ------------+-----------+----------------+-------------
  82. Andrew | Fuller | 34 | 39
  83. Anne | Dodsworth | 16 | 19
  84. Janet | Leverling | 30 | 38
  85. Laura | Callahan | 23 | 31
  86. Margaret | Peacock | 33 | 44
  87. Michael | Suyama | 17 | 19
  88. Nancy | Davolio | 32 | 42
  89. Robert | King | 21 | 25
  90. Steven | Buchanan | 11 | 13
  91. (9 rows)
  92. ---------------------------------------- Question 20 Query ----------------------------------------
  93. SELECT COUNT(*) FROM orders WHERE ship_country='Sweden' AND shipped_date BETWEEN order_date AND order_date + INTERVAL '7 day';
  94. ---------------------------------------- Question 20 Results --------------------------------------
  95. count
  96. -------
  97. 15
  98. (1 row)
  99. ---------------------------------------- Question 21 Query ----------------------------------------
  100. SELECT products.product_name FROM suppliers FULL JOIN products ON suppliers.supplier_id=products.supplier_id WHERE suppliers.company_name='Leka Trading';
  101. ---------------------------------------- Question 21 Results --------------------------------------
  102. product_name
  103. -------------------------------
  104. Singaporean Hokkien Fried Mee
  105. Ipoh Coffee
  106. Gula Malacca
  107. (3 rows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement