Learn SQL, the same hands-on way
SQL is how analysts get data out of databases. Write real queries against a real database in your browser, and like the Excel lessons, every query is also tested on data you haven’t seen.
0 of 21 lessons done
- Start
SELECT
1. Getting data out with SELECT
Ask a table for the columns you want.
- Start
WHERE
2. Filtering rows with WHERE
Return only the rows that match.
- Start
ORDER BY, LIMIT and DISTINCT
3. Sorting and limiting
Put results in order, take the top few, and remove duplicates.
- Start
LIKE, IN, BETWEEN and NULL
4. Patterns, lists and missing values
Flexible filters, and how to find what’s missing.
- Start
Aggregate functions
5. Summaries with COUNT, SUM and AVG
Turn many rows into one number.
- Start
GROUP BY and HAVING
6. Grouping with GROUP BY
A summary for each group, like a PivotTable.
- Start
JOIN
7. Combining tables with JOIN
Pull related data together, like a lookup.
- Start
Subqueries and UNION
8. Subqueries and UNION
Use one query’s result inside another.
- Start
CASE
9. Labels and buckets with CASE
Turn values into categories inside a query.
- Start
Text functions
10. Working with text
Change case, join and cut text.
- Start
Arithmetic, ROUND and COALESCE
11. Calculations and missing values
Do maths in a query, and handle NULL.
- Start
Self joins
12. Joining a table to itself
Find managers, and count their teams.
- Start
Common table expressions
13. Step by step with WITH
Break a hard query into named steps.
- Start
Window functions
14. Rankings and running totals
Rank rows and add running totals without grouping them away.
- Start
EXISTS
15. Checking for matches with EXISTS
Find rows that do, or don’t, have a match elsewhere.
- Start
INTERSECT and EXCEPT
16. Combining results with INTERSECT and EXCEPT
Find what two results share, or what one has that the other doesn’t.
- Start
COUNT DISTINCT and GROUP_CONCAT
17. Counting carefully
Distinct counts, NULLs in counts, and lists in one cell.
- Start
LAG and LEAD
18. Comparing with the previous row
Changes from one row to the next, and year-on-year growth.
- Start
CREATE TABLE and CREATE VIEW
19. Creating tables and views
Define tables, add columns, and save queries as views.
- Start
Putting it together
20. Building reports
Shares, complete lists and top customers.
- Start
INSERT, UPDATE and DELETE
21. Changing data
Add, change and remove rows safely.