4 weeks ago
18 lines465 B
SELECT c.name, o.ordered_at, o.total | |
FROM customers AS c | |
JOIN orders AS o ON o.customer_id = c.id | |
WHERE o.total > 100 | |
ORDER BY o.ordered_at DESC | |
LIMIT 10; | |
| |
-- Customers who never ordered: LEFT JOIN and look for the missing side | |
SELECT c.name | |
FROM customers AS c | |
LEFT JOIN orders AS o ON o.customer_id = c.id | |
WHERE o.id IS NULL; | |
| |
-- Try changing the values above and run it again. | |
| |
-- Questions? Ask in the course forum. | |
| |
-- This is the version we use in the video. |