Courses / Beginner
SQL Essentials
Ask questions of real data: SELECT, JOIN, GROUP BY and window functions on a store's orders database.
8 lessons7 hours301k learnersCertificate with Pro
Code you'll write
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;
-- Revenue per month
SELECT strftime('%Y-%m', ordered_at) AS month,
COUNT(*) AS orders,
SUM(total) AS revenue
FROM orders
GROUP BY month
HAVING revenue > 5000
ORDER BY month;
SELECT name, department, salary,
RANK() OVER (PARTITION BY department ORDER BY salary DESC) AS rank
FROM employees;