Challenging SQL problems
Warning
These questions are not for people new to SQL! Most of them expect you to use advanced SQL techniques that aren't widely known.
Note
The database versions used for the solutions can be found at the top of the following page:
Problems
🟤 Bronze Tier
As long as you know your database features and query patterns, these are fairly straightforward.
- Temperature anomaly detection
- Outstanding invoices
- Personalised customer emails
- Suspicious login activity
- Combining dimensions
- Customer churn
- Fibonacci sequence
- UK bank holidays
⚪ Silver Tier
These require a bit more thinking.
- Metric correlation
- Funnel analytics
- Bannable login activity
- Bus routes
- Decoding datelist ints
- Region precipitation
- Predicting values
- Mandelbrot set
- Customer sales running totals
🟡 Gold Tier
Expect to spend a bit of time on these.
Questions by topic
To see the questions grouped by topic, head over to the topics page.
Looking for more?
The repo billwallis/sql-models has a collection of custom SQL models, some of which come with exercises.
For example, the loans model has exercises ranging from very easy to very hard: