Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------- Question 16 Query ----------------------------------------
- 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;
- ---------------------------------------- Question 16 Results --------------------------------------
- first_name | last_name | count
- ------------+-----------+-------
- Andrew | Fuller | 96
- Janet | Leverling | 127
- Laura | Callahan | 104
- Margaret | Peacock | 156
- Nancy | Davolio | 123
- (5 rows)
- ---------------------------------------- Question 17 Query ----------------------------------------
- SELECT product_name FROM products WHERE unit_price < (SELECT AVG(unit_price) FROM products);
- ---------------------------------------- Question 17 Results --------------------------------------
- product_name
- ----------------------------------
- Chai
- Chang
- Aniseed Syrup
- Chef Anton's Cajun Seasoning
- Chef Anton's Gumbo Mix
- Grandma's Boysenberry Spread
- Queso Cabrales
- Konbu
- Tofu
- Genen Shouyu
- Geitost
- Pavlova
- Teatime Chocolate Biscuits
- Sir Rodney's Scones
- Gustaf's Knäckebröd
- Tunnbröd
- Guaraná Fantástica
- NuNuCa Nuß-Nougat-Creme
- Nord-Ost Matjeshering
- Gorgonzola Telino
- Sasquatch Ale
- Steeleye Stout
- Inlagd Sill
- Gravad lax
- Chartreuse verte
- Boston Crab Meat
- Jack's New England Clam Chowder
- Singaporean Hokkien Fried Mee
- Gula Malacca
- Rogede sild
- Spegesild
- Zaanse koeken
- Chocolade
- Maxilaku
- Valkoinen suklaa
- Filo Mix
- Tourtière
- Pâté chinois
- Ravioli Angelo
- Escargots de Bourgogne
- Sirop d'érable
- Louisiana Fiery Hot Pepper Sauce
- Louisiana Hot Spiced Okra
- Laughing Lumberjack Lager
- Scottish Longbreads
- Outback Lager
- Flotemysost
- Röd Kaviar
- Longlife Tofu
- Rhönbräu Klosterbier
- Lakkalikööri
- Original Frankfurter grüne Soße
- (52 rows)
- ---------------------------------------- Question 18 Query ----------------------------------------
- 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;
- ---------------------------------------- Question 18 Results --------------------------------------
- count
- -------
- 6
- (1 row)
- ---------------------------------------- Question 19 Query ----------------------------------------
- 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;
- ---------------------------------------- Question 19 Results --------------------------------------
- first_name | last_name | unique_clients | order_count
- ------------+-----------+----------------+-------------
- Andrew | Fuller | 34 | 39
- Anne | Dodsworth | 16 | 19
- Janet | Leverling | 30 | 38
- Laura | Callahan | 23 | 31
- Margaret | Peacock | 33 | 44
- Michael | Suyama | 17 | 19
- Nancy | Davolio | 32 | 42
- Robert | King | 21 | 25
- Steven | Buchanan | 11 | 13
- (9 rows)
- ---------------------------------------- Question 20 Query ----------------------------------------
- SELECT COUNT(*) FROM orders WHERE ship_country='Sweden' AND shipped_date BETWEEN order_date AND order_date + INTERVAL '7 day';
- ---------------------------------------- Question 20 Results --------------------------------------
- count
- -------
- 15
- (1 row)
- ---------------------------------------- Question 21 Query ----------------------------------------
- SELECT products.product_name FROM suppliers FULL JOIN products ON suppliers.supplier_id=products.supplier_id WHERE suppliers.company_name='Leka Trading';
- ---------------------------------------- Question 21 Results --------------------------------------
- product_name
- -------------------------------
- Singaporean Hokkien Fried Mee
- Ipoh Coffee
- Gula Malacca
- (3 rows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement