12 months ago
15 lines427 B
-- Products more expensive than the average | |
SELECT name, price | |
FROM products | |
WHERE price > (SELECT AVG(price) FROM products); | |
| |
-- Each customer's biggest order | |
SELECT c.name, big.max_total | |
FROM customers AS c | |
JOIN (SELECT customer_id, MAX(total) AS max_total | |
FROM orders GROUP BY customer_id) AS big | |
ON big.customer_id = c.id; | |
| |
-- Questions? Ask in the course forum. | |
| |
-- Try changing the values above and run it again. |