SQL course · Role-specific preparation
SQL Interview Preparation: What Recruiters Actually Test
Build a role-specific SQL interview preparation plan with an analyst-versus-developer skills matrix and a sample take-home task.
Original PostgreSQL examples · Learn the method, test the output, explain the result.
Core idea
Use the job description to choose the SQL problems you rehearse.
Developer → data access + correctness
Both → explain the result
The direct answer
Prepare for the role named in the invitation.
There is no single universal SQL interview. A data analyst role may stress metric definitions, joins and reporting outputs; a backend role may stress data access, correctness, constraints and performance reasoning. Both can ask you to write a query and explain why its rows are right. Use the actual vacancy and interview instructions to decide which skills deserve the most practice.
This page gives a role-specific competency matrix, a sample take-home task, an evaluation rubric and a way to turn mistakes into a study plan. The matrix is a preparation framework, not a claim about what every recruiter tests. For broader technical interview context, see Heycademy’s technical interview guide. SQL course options follow this overview.
Course access
Choose your next step in SQL.
Review the current course options and access details here.
Heycademy Courses · Coming Soon
Master SQL with Heycademy
We’re preparing an interactive learning experience with practical exercises, skill assessments and personalized learning to help you build confidence and master new skills.
We’re putting the finishing touches on this course. Please check back for updates.
Read the available evidence
Turn role language into a task list.
Copy the exact database, data tool and work tasks from the job description. “Build weekly dashboards” suggests grouped metrics and date handling. “Design APIs backed by PostgreSQL” suggests data access, constraints and explaining a query plan. “Investigate data quality” suggests nulls, duplicate identities and validation. Ask the recruiter about the format when the invitation leaves it unclear.
Do not infer an employer’s test from a generic online list. A live SQL editor, whiteboard discussion, take-home analysis and multiple-choice screen reveal different skills. Prepare the common core, then rehearse the interaction you have actually been told to expect.
Original competency matrix
Shared core, different emphasis.
| Skill | Analyst-oriented prompt | Backend-oriented prompt | Evidence of competence |
|---|---|---|---|
| Filtering and joins | Combine customer and order data for a report. | Fetch related records without duplicate expansion. | State keys and expected grain. |
| Aggregation | Define active customers or monthly revenue. | Summarise operational data correctly. | Name numerator, denominator and exclusions. |
| Window functions | Rank regions and compare periods. | Find latest event per account. | State partition, order and tie rule. |
| Nulls and missing rows | Explain missing dimension values. | Handle optional fields and anti-joins. | Test NULL and absent-match cases. |
| Performance | Avoid wasteful report query. | Discuss indexes and plan evidence. | Measure on representative data before claiming speed. |
| Communication | Explain a metric to a stakeholder. | Explain correctness and data access to an engineer. | Show assumptions and a small verification case. |
Some analyst positions require advanced optimisation; some developer interviews focus mainly on basic joins. Reweight the matrix using the vacancy. A practical default is to secure the shared core before spending all study time on a specialised topic.
Sample take-home task
Produce a result a reviewer can check.
Original prompt: A shop has customer and order tables. Return one row per customer showing the count and total of paid orders placed in February 2026. Keep customers with no paid February orders and show zero for them. Explain how you would check the output. This is an illustrative exercise, not an employer’s private task.
| customer | February paid orders | expected paid total |
|---|---|---|
| Ada | 1 | 40 |
| Ben | 0 | 0 |
| Cleo | 0 | 0 |
WITH feb_paid AS (
SELECT customer_id, COUNT(*) AS paid_orders, SUM(amount) AS paid_total
FROM orders
WHERE status='paid'
AND order_date >= DATE '2026-02-01'
AND order_date < DATE '2026-03-01'
GROUP BY customer_id
)
SELECT c.name, COALESCE(f.paid_orders,0) AS paid_orders,
COALESCE(f.paid_total,0) AS paid_total
FROM customers c LEFT JOIN feb_paid f ON f.customer_id=c.id
ORDER BY c.id;The sample assumes a proper date column and one customer row per id. The exclusive upper bound handles all timestamps within February when the column is timestamp-like; adapt the literal type to your actual schema. Aggregating paid February orders before the LEFT JOIN gives one metric row per customer and preserves customers with no qualifying order.
Verification: inspect one customer with a paid February order, one with only a pending order, and one with no orders. Count their qualifying order rows by hand. A right-table status or date filter added to the outer WHERE could remove the zero rows, so keep the qualifying conditions inside the CTE.
Keep building this skill
Apply the method on fresh SQL problems.
The course options are above. Return to the synced pricing block whenever you are ready.
Review the answer
A useful interview self-review rubric.
| Criterion | Question | Repair if weak |
|---|---|---|
| Correctness | Do rows and totals match the tiny expected case? | Trace intermediate rows and recompute by hand. |
| Assumptions | Are date, status, null and customer-identity rules stated? | Write the unresolved business choices. |
| Maintainability | Could another person see where the metric is defined? | Name the intermediate set and remove unnecessary complexity. |
| Transfer | Does the query work when a new customer has no orders? | Add that row and rerun. |
| Performance reasoning | Are claims supported by a real plan and data? | Measure before recommending an index. |
A strong answer can include a question back to the interviewer: “Does refunded revenue count as paid revenue?” That clarification is often more valuable than guessing. Once the business definition is fixed, the SQL can be tested against it.
Use the matrix
Select practice by observed gap.
If an analyst task fails on denominator or status rules, practise grouped metrics and explain the business definition. If a developer task fails on duplicate expansion, revisit joins and one-to-many relationships. If the query works but the explanation is unclear, rehearse describing grain, filter order and the verification dataset. The 14-day plan schedules these checks, while the 20-question set supplies fresh query tasks.
Prepare for the actual interaction
The same SQL skill can be tested in different ways.
| Interview format | What to rehearse | Evidence to bring |
|---|---|---|
| Live editor | Write a query, run it, explain a failed case. | Small expected-output example and one edge case. |
| Verbal walkthrough | Describe grain, joins and filter order aloud. | Plain-language reasoning before syntax details. |
| Take-home task | Document assumptions and verify outputs. | Reproducible query, sample rows and limitations. |
| Multiple-choice screen | Trace clause behavior without execution. | Mental row counts and null/tie rules. |
For a live editor, practise using the available dialect and debugging a syntax error without panic. For a verbal discussion, use a tiny data example to make the result visible; reciting clause definitions is usually less useful. For a take-home exercise, give the reviewer enough information to reproduce your result and inspect the assumptions. In every format, respect the employer’s stated rules about external tools, data confidentiality and time limits.
A sample preparation prompt for an analyst is “one row per region with paid February revenue.” For a developer it might be “the latest successful event per account, including accounts with no success.” Both require a definition of missing rows and a verification case, but the emphasis differs. Choose your two rehearsal prompts from the vacancy rather than assuming one template covers every role.
Check exact SQL behavior
Use the database’s own documentation.
When the invitation names PostgreSQL, consult its official table-expression reference for join, filter and grouping semantics. For another engine, consult that engine’s documentation instead of assuming identical syntax. This matters especially for date functions, null-safe equality and execution plans. Build your own small verification dataset before turning a remembered example into an interview answer.
FAQ
Questions about this skill.
Do all recruiters test window functions?
No. Use the role description and interview instructions. Windows are valuable for many data tasks but are not universal.
Should I optimise my query before verifying the result?
Verify correctness first. Then discuss a plan, realistic data and workload if performance is relevant.
Is the sample take-home task an official employer task?
No. It is an original teaching case designed to make the assessment criteria visible.
Continue with the SQL course
Make this skill reliable on new data.
Return to the course options and choose the next learning step.