New: 6 free SQL practice datasets with 300+ questions — try the SQL Compiler →
SQL

How to Prepare for a SQL Interview: A Plan

How to prepare for a SQL interview: what rounds test, a topic checklist, a practice loop with timed quizzes, an error log and an interview-day checklist.

Upskly AI Team September 24, 2026 6 min read
How to Prepare for a SQL Interview: A Plan

Preparing for a SQL interview is mostly about recall under pressure. An interview does not hand you a reference sheet, a search bar or unlimited time. It hands you a problem and watches what you do with it. Most people prepare by reading, which is the one form of practice that never puts them under that pressure.

This guide is a practical plan: what SQL interviews test, a topic checklist, a practice loop that uses quizzes well, an error log to turn mistakes into progress, and a checklist for the day itself.

In this guide

What SQL interviews test

Formats vary by company and role, but SQL usually shows up in one or more of these:

Common SQL interview formats
FormatWhat it looks likeWhat it rewards
Online screening testTimed multiple-choice or short queriesFast, accurate recall of syntax and behaviour
Live SQL codingWrite queries in a shared editor while talkingClear thinking, clarifying questions, testing your own work
Take-home or case studyAnalyse a dataset and report findingsCorrectness, judgement about what to include, communication
DiscussionExplain a past query, a bug or performanceDepth of understanding, not just syntax

Interviewers are not grading only whether your query runs. They are looking at whether you ask about ties, NULLs and edge cases, and whether you can explain why your answer is right.

The topic checklist

Work through these in order and use the deep-dive guides where a topic feels shaky:

SQL interview topics
TopicA typical questionThe classic trapGuide
JoinsCustomers who never orderedINNER JOIN silently drops the rows you wantSQL Joins Explained
AggregationCustomers with more than 3 ordersFiltering before vs after groupingSQL WHERE vs HAVING
NULL handlingCount customers with a phone number= NULL, NOT IN, COUNT(*) vs COUNT(col)NULL in SQL
Subqueries and CTEsAbove the department averageNested logic that becomes unreadableSubquery vs CTE
Window functionsTop earner per departmentTies: RANK vs ROW_NUMBERSQL Window Functions
Real questionsSecond-highest salary, duplicates, streaksThe obvious answer is wrongSQL Interview Questions

Here are the links: joins, WHERE vs HAVING, NULL, subqueries and CTEs, window functions and nine worked interview questions.

The practice loop

  1. Learn one topic from the checklist.
  2. Quiz yourself on that topic only. A wrong answer points at a specific gap.
  3. Log every mistake (see below), including why you chose the wrong answer.
  4. Write the query again from a blank editor in our free SQL editor, without looking at the solution.
  5. Retake the topic a few days later. Recall that survives a gap is recall that will survive an interview.
  6. Mix topics under a timer once each one feels solid, because a real screening test does not tell you which technique to use.
  7. Explain your answer out loud. If you cannot say why it works, you do not fully know it yet.

Three ways to practise

Practice modes
ModeWhen to use itHow
Untimed, one topicWhen a topic is newTake your time, read every explanation
Timed, one topicWhen the topic feels familiarAdd a timer and see if recall holds
Timed, mixed topicsIn the last stretch before the interviewRandom mix, so you must recognise the technique first

A quiz format with a running clock, and an explanation you only see after you answer, is the closest free rehearsal for a live screen. Our SQL quiz works that way: free with a quick sign-in, every quiz timed and scored, and a written explanation for every answer. It will not feel comfortable, and that is the point. Comfortable practice does not prepare you for an uncomfortable moment.

Keep an error log

An interview is not graded on what you already knew. It is graded on the gaps. Reviewing what you got wrong tells you where to spend your next hour, while reviewing what you got right just feels good. Keep a simple log:

Error log (example row)
QuestionWhat I answeredWhy it was wrongRule to remember
Customers with more than 1 completed orderHAVING COUNT(*) > 1Forgot to filter out cancelled orders firstRow filters go in WHERE, before grouping

Here is that exact mistake, so you can see why it is easy to make. The table:

Table: orders
order_idcustomer_idamountstatus
1011500completed
1021300cancelled
1032700completed

My answer:

SELECT customer_id, COUNT(*) AS orders
FROM orders
GROUP BY customer_id
HAVING COUNT(*) > 1;
Output: customer 1 appears, but they have only 1 completed order
customer_idorders
12

Customer 1 has two orders, but one is cancelled. Counting every row includes it. The fix: filter first with WHERE, then count.

SELECT customer_id, COUNT(*) AS completed_orders
FROM orders
WHERE status = 'completed'
GROUP BY customer_id
HAVING COUNT(*) > 1;
Output: no customer has more than 1 completed order
customer_idcompleted_orders
0 rows returned

Writing the rule in your own words (“filter rows before grouping”) is what stops you repeating the mistake.

Want to run this yourself? Copy the setup SQL
CREATE TABLE orders (order_id INT, customer_id INT, amount INT, status VARCHAR(20));
INSERT INTO orders VALUES (101, 1, 500, 'completed'), (102, 1, 300, 'cancelled'), (103, 2, 700, 'completed');

Works in MySQL, PostgreSQL and SQLite. Paste it into any of them, then run the queries from this guide.

Interview-day checklist

  • Clarify before you type. Ask about ties, NULLs, duplicates and what should be excluded, such as cancelled or refunded orders.
  • Say your plan first. “I will join the tables, group by department, then rank.”
  • Build in small steps and check the intermediate result as you go.
  • Test on a tiny example out loud, including an edge case such as a tie or a NULL.
  • Name the trap you avoided. It shows you understand why the wrong answer is tempting.
  • If you get stuck, say what you have tried and what you would check next. Silence is worse than a partial idea.

Frequently asked questions

How long should I prepare for a SQL interview?

It depends on your starting point and the role. What matters more than the number of days is coverage of the core topics (joins, aggregation, NULLs, subqueries, window functions) and repeated practice under time pressure.

What SQL topics should I prepare?

Joins, GROUP BY with HAVING, NULL handling, subqueries and CTEs, and window functions, plus the classic questions such as second-highest salary, duplicates and “never ordered” queries.

Are online quizzes good preparation for a SQL interview?

They are good for finding gaps and rehearsing recall under a timer. Pair them with writing queries from a blank editor and explaining your answers out loud.

Should I memorise SQL syntax?

Know the core well enough to write it without looking. For less common functions, it is fine to say which one you would use and check the exact syntax, as you would at work.

What if I get a question I do not know?

Talk through what you do know. State the goal, break it into steps and try the parts you can do. Interviewers usually value your reasoning as much as the final query.

Practise under a real timer

Free SQL quiz with a quick sign-in. Timed, scored, with an explanation for every answer.

Take the SQL Quiz →

Want a structured path instead?

Structured SQL courses – built for exactly this kind of interview prep.

Browse SQL Courses →
Upskly AI Team
Learning made simple
Scroll to Top