Querydrill

Free SQL practice test for interviews

Ten hands-on questions you answer by writing real queries against a live database, one 15-minute clock, and a score broken down by skill area. No sign-up to start.

Questions
10
Minutes
15
Skill areas
6
Price
Free
select * from test_result;Example result

Working knowledge

Correct
7 of 10
Time
12:48 of 15:00
Skill areaScoreShare correct
Basics1/1
Strong
Aggregation2/2
Strong
Joins1/2
Review
Advanced1/2
Review
Interview classics1/2
Review
Work mode and case studies1/1
Strong
An example of the result you get: a score, your time, and each skill area marked.

What the test covers

SQL screens for analyst, data and backend roles draw on the same short list of skills. The test takes its ten questions from all six, picked at random each time.

  • Basics

    Picking columns, filtering with several conditions, sorting, LIMIT, NULL handling and CASE. SELECT, WHERE, ORDER BY, CASE

    1 of 1020 exercises
  • Aggregation

    Counts and totals per group, filtering groups, conditional aggregates and revenue by month. GROUP BY, HAVING, COUNT, SUM

    2 of 1024 exercises
  • Joins

    Inner and left joins, self joins, rows with no match, and totals across joined tables without double counting. JOIN, LEFT JOIN, IS NULL, UNION ALL

    2 of 1026 exercises
  • Advanced

    Subqueries, CTEs and window functions: ranking within a group, running totals, change from the previous row. WITH, RANK, LAG, SUM OVER

    2 of 1029 exercises
  • Interview classics

    The questions that keep coming back: the Nth highest salary, earns more than the manager, median, cohort retention. DENSE_RANK, self join, pivot with CASE

    2 of 1028 exercises
  • Work mode and case studies

    A request from a colleague on messy raw tables: mixed capitals and spaces, amounts stored as text, mixed date formats, duplicate accounts. TRIM, UPPER, REPLACE, CAST

    1 of 1034 exercises
No sign-up. No card.

Three sample questions

These come from the same pool as the test. In the test you write the query in an editor, run it against the tables as often as you like, and it is checked on the data you see and again on a changed copy.

Q1Repeat buyers

Aggregation

Return the customer_id of every customer who placed more than two orders, whatever the status.

orders14 rows

idcustomer_idorder_dateamountstatus
10112025-01-03120paid
10212025-01-2080.5paid
10322025-01-22200paid
10432025-02-0245refunded
10532025-02-15310paid
10642025-02-18150pending
10752025-03-0160paid
10862025-03-0995paid
10962025-03-30130paid
11062025-04-1175paid
11172025-04-12210paid
11212025-04-2540paid
11322025-05-06180refunded
11432025-05-19220paid
Show the answer

QuerySELECT customer_id FROM orders GROUP BY customer_id HAVING COUNT(*) > 2

HAVING filters groups after aggregation; WHERE filters rows before it.

Open this exercise

Q2Customers who never ordered

Joins

Return the names of customers who have no orders at all.

customers8 rows

idnamecountrysignup_date
1AnnaNL2024-01-05
2BrunoBR2024-02-11
3ChloeUS2024-03-02
4DevIN2024-03-19
5ElifTR2024-05-27
6FarahUS2024-06-14
7GusNL2024-08-01
8HanaJP2024-09-09

orders14 rows

idcustomer_idorder_dateamountstatus
10112025-01-03120paid
10212025-01-2080.5paid
10322025-01-22200paid
10432025-02-0245refunded
10532025-02-15310paid
10642025-02-18150pending
10752025-03-0160paid
10862025-03-0995paid
10962025-03-30130paid
11062025-04-1175paid
11172025-04-12210paid
11212025-04-2540paid
11322025-05-06180refunded
11432025-05-19220paid
Show the answer

QuerySELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL

LEFT JOIN plus IS NULL on the right side is the standard way to find rows with no match.

Open this exercise

Q3Top earner per department

Advanced

Return the dept_id, name and salary of the highest-paid employee in each department. If several employees share the top salary in a department, return all of them. Ignore employees without a department.

employees11 rows

idnamedept_idsalaryhire_datemanager_id
1Ava21300002019-03-15NULL
2Ben21050002020-07-011
3Cleo1820002021-01-107
4Dan1760002022-05-237
5Eve3540002022-09-1211
6Finn2980002021-11-301
7Gia1990002018-06-04NULL
8Hugo3610002020-02-18NULL
9Iris4880002019-10-07NULL
10Jack4720002023-04-179
11KaiNULL500002024-01-088
Show the answer

QuerySELECT dept_id, name, salary FROM (SELECT dept_id, name, salary, RANK() OVER (PARTITION BY dept_id ORDER BY salary DESC) AS r FROM employees WHERE dept_id IS NOT NULL) WHERE r = 1

Top-N per group is a classic interview question: rank in a subquery or CTE, then filter on the rank.

Open this exercise

How scoring works

  • Each question is worth one point. You get the point when your query returns the right rows on the tables shown and again on a changed copy with extra rows and updated values, so an answer typed in as a fixed value does not score.
  • Row order is checked only when the question asks for an order, and column names do not matter. You can run and check a query as often as you like while the clock runs. A question you skip, or have not solved when the 15 minutes end, counts as wrong.
  • The result shows your score out of 10, the time you took, and each skill area as strong or to review, with links to the exercises for the areas you missed.

What your score means

  • 0 to 4Build the basics first

    Start with the first levels and work up. Short daily practice moves this score quickly.

  • 5 to 7Working knowledge

    The core is there. The areas you missed are the ones to drill before a timed screen.

  • 8 to 10Interview-ready on this set

    You solved questions from nearly every level under the clock. Drill the one or two areas you missed and you are in good shape.

These bands describe this test only. Employers set their own pass marks, and we do not know them.

Take the test

10 questions from 6 skill areas, 15 minutes on the clock. It starts right here, with no account and no email.

  • Hints and solutions are off while the clock runs.
  • Run and check a query as often as you like. Skip counts as wrong.
  • Your answers survive a page reload.

The mistakes that cost the most points

The checker on Querydrill names these when it sees them. Fix them before a timed test.

  • WHERE where HAVING belongs. A condition on COUNT or SUM filters groups, so it goes in HAVING, after GROUP BY. WHERE runs before the rows are grouped.
  • An inner join that drops rows. Customers with no orders vanish from an inner join. LEFT JOIN keeps them, and COALESCE turns the missing total into 0.
  • A join that repeats rows. Joining orders to their items before summing the order amount counts each order once per item. Aggregate first, or count with DISTINCT.
  • Integer division. In PostgreSQL 7 / 2 is 3. Multiply by 1.0 before dividing when the question asks for a share or an average.
  • Values typed into the query. Filtering on the id you can see in the sample rows is right today and wrong when the data changes, which is why every answer here is checked on a second copy of the data.
  • LIMIT without ORDER BY. The top three of an unsorted result is an arbitrary three. Sort first, and add DESC for largest first.

The three formats a SQL test comes in

  • Multiple choice about SQL knowledge: what a LEFT JOIN returns, where HAVING goes, what NULL = NULL evaluates to.
  • Live queries against a database, usually timed: read the tables, write the query, return the right rows. This test is that format, because knowing a clause and writing it under a clock are different skills.
  • A take-home case: raw tables and a list of business questions. Accuracy matters more than speed, and cleaning the data is tested as much as the queries.

Questions

Is the SQL practice test really free?

Yes. The test is free and you do not need a card. Free visitors get one attempt a day; Pro members can retake it any time.

Do I need an account or a database installed?

No to both. The test starts in one click and runs on PostgreSQL inside your browser, with the tables already loaded. Most questions use standard SQL, including window functions and CTEs; a few date questions use PostgreSQL's date functions such as to_char.

How long does the test take?

Up to 15 minutes. There are 10 questions on one clock, and the test ends when you finish the last question or the time runs out.

How is the test scored?

One point per question, 10 in total. A query scores when it returns the right rows on the tables shown and again on a changed copy of the data. Skipped or unsolved questions count as wrong. You also get a breakdown by skill area.

Is it like the SQL test employers use?

It uses the hands-on format: you write real queries against tables under a clock, which is how live SQL screens and online assessments work. It is not a copy of any employer's or testing company's test, and it does not include multiple-choice questions, schema design or query tuning.

Can I retake the test?

Yes. The questions are drawn at random from the exercise pool, so a retake is a different test. Free visitors can retake it the next day; Pro removes the limit.

What comes after the test?

Your result links straight to the exercises for the areas you missed. Your first 8 exercises on Querydrill are free without an account, and questions you solve in the test count toward them. Pro unlocks all 161 exercises, every reference solution, timed mode and the certificate.

Find out where you stand

Ten questions, 15 minutes, a score by skill area. Free, and no sign-up to start.