Practice data and prompts
SQL practice datasets with questions and answers
Work through 78 free SQL questions on 5
realistic relational datasets. Every set progresses from basic grouping
and joins to reporting problems involving rates, time periods, window
functions, and query grain. Open a prompt in the browser or download the
full dataset and use your own SQL tools.
Each answer is real SQL checked against the same browser sample you query.
Solutions are collapsed on the dataset guide, so you can attempt the
question first and reveal the answer when you are ready. These are
open-ended result questions rather than multiple-choice quizzes.
intermediate · 7 tables · 15
questions
Ecommerce Orders
Customers, products, orders, line items, payments, and returns at realistic online-retail volume.
Try all 15 →
-
Beginner
How many orders are in the dataset, and how many distinct customers placed them?
Open question and answer →
-
Intermediate
What is the gross revenue of each top-level category? Roll child categories up into their parent.
Open question and answer →
-
Advanced
Compute total revenue two ways: the naive way, joining orders to order_items and payments in one query, and the correct way, aggregating each child table to one row per order first. Return both totals, the amount the naive query overstates, and by what percentage.
Open question and answer →
advanced · 5 tables · 15
questions
Banking Transactions
Accounts, merchants, and two years of posted transactions with no stored balance to read off.
Try all 15 →
-
Beginner
How many transactions are there in total, and how many distinct accounts do they cover?
Open question and answer →
-
Intermediate
For the busiest account in the data, show each transaction with the running balance after it. Debits subtract, credits add.
Open question and answer →
-
Advanced
Find the duplicate card payments: same account, same merchant, same amount, posted no more than 15 elapsed minutes after the one before it. Return both timestamps and the amount.
Open question and answer →
advanced · 6 tables · 15
questions
SaaS Subscriptions
Organizations, plan intervals, invoices, and product usage for a B2B SaaS business.
Try all 15 →
-
Beginner
How many organizations are there in each industry, biggest first?
Open question and answer →
-
Intermediate
What was live monthly recurring revenue at the end of each month? A subscription counts for a month if it had started and had not yet ended.
Open question and answer →
-
Advanced
Take each organization's first subscription month as its cohort. For each cohort, how many organizations were subscribed at the start of the month six months later?
Open question and answer →
intermediate · 5 tables · 15
questions
Marketing Campaigns
Channels, campaigns, ad groups, and two years of daily performance where every metric is a ratio.
Try all 15 →
-
Beginner
How many campaigns run on each channel, and how many are still running?
Open question and answer →
-
Intermediate
Calculate the real click-through rate for each channel: total clicks divided by total impressions. Guard against channels with no impressions.
Open question and answer →
-
Advanced
Compare first-touch and last-touch attribution. For each channel, how many conversions and how much revenue does each model give it?
Open question and answer →
intermediate · 6 tables · 18
questions
Messy Student Records
Student, enrollment, and grade records merged from three schools, with the mixed formats, padding, and duplicates left to clean.
Try all 18 →
-
Beginner
How many different ways is an enrollment's status written, and how many rows use each one?
Open question and answer →
-
Intermediate
What are the ten most-enrolled courses once the course codes are cleaned to the catalog's form?
Open question and answer →
-
Advanced
Parse enrolled_on into a real date using each school's own format. How many dates per school would land on the wrong day if you read them all as US dates?
Open question and answer →
How to use the questions
- 1. Read the schema
Identify the result grain, keys, and table relationships before
writing the query.
- 2. Run your answer
Open the prompt in SQLShed or download the files and work in your
usual database client.
- 3. Compare solutions
Reveal the tested answer, then compare result grain, filters, joins,
grouping, and tie-breakers, not only the final rows.
Questions about the practice sets
Do these SQL dataset questions include answers?
Yes. Every question has a tested SQL solution on its dataset page. The solution stays collapsed until you choose to reveal it.
Can I run the SQL questions online?
Yes. Each question opens in SQLShed's browser playground with the correct dataset and a prompt in the editor. Nothing needs to be installed.
Can I download the practice datasets?
Yes. Each dataset guide links its available full downloads, including CSV, SQL, Parquet, or schema files depending on the dataset.