Data Coding
SQL
Python
Practice
Pricing
SQL course
Short lessons, each with exercises you run in your browser.
0
Start here
−
0.1
How SQL reads your query
0.2
How to answer an interview SQL question
1
Basics: select, filter, sort
−
1.1
SELECT
1.2
WHERE
1.3
NULL
1.4
ORDER BY and LIMIT
2
Aggregation
Pro
−
2.1
COUNT, SUM, AVG
2.2
GROUP BY
2.3
WHERE vs HAVING
2.4
Ratios and percentages
3
CASE WHEN and conditional aggregation
Pro
−
3.1
CASE WHEN
3.2
Count and sum only some rows
3.3
Pivot
3.4
Unpivot
3.5
Buckets and histograms
4
CTEs: build a query step by step
Pro
−
4.1
WITH
4.2
Put one total on every row
4.3
Several metrics in one row
4.4
Keep dates and thresholds in one place
4.5
Make your own test data
5
Joins
Pro
−
5.1
INNER JOIN
5.2
LEFT JOIN
5.3
LEFT JOIN
5.4
Find rows with no match
5.5
Join fan-out
5.6
Self join
5.7
CROSS JOIN
5.8
FULL OUTER JOIN and joining on a range
5.9
Recursive CTE
6
Dates and times
Pro
−
6.1
Dates, timestamps and casting
6.2
Pull out parts of a date
6.3
Date math
6.4
Time between two timestamps
6.5
Fill in missing dates
7
Strings and types
Pro
−
7.1
Clean and join text
7.2
Take pieces of a string
7.3
Pattern matching and whole words
7.4
Lists inside one cell
7.5
Types and casting
8
Stacking results and duplicates
Pro
−
8.1
UNION and UNION ALL
8.2
INTERSECT and EXCEPT
8.3
Find and remove duplicates
8.4
Two-way relationships
9
Window functions 1: ranking and totals
Pro
−
9.1
OVER()
9.2
ROW_NUMBER, RANK and DENSE_RANK
9.3
Top N per group and latest row per group
9.4
Rank, then put the winners side by side
9.5
NTILE and PERCENT_RANK
10
Window functions 2: across rows over time
Pro
−
10.1
LAG and LEAD
10.2
Running totals
10.3
Window frames
10.4
FIRST_VALUE and LAST_VALUE
10.5
Forward fill and back fill
11
Statistics in SQL
Pro
−
11.1
Median and percentiles
11.2
Median from a count table
11.3
Mode, spread and outliers
11.4
Correlation
12
Analytics patterns
Pro
−
12.1
Active users
12.2
Funnels
12.3
Retention and cohorts
12.4
Streaks
12.5
Sessions from raw events
12.6
Overlaps and "at the same time"
12.7
Social network questions
12.8
Growth, rolling totals and churn
13
Toolbox: tips and tricks
Pro
−
13.1
Same idea, other databases
13.2
Debugging a wrong answer
13.3
Writing SQL other people can read
13.4
Quick reference