Many data analyst hiring processes start with an online SQL assessment: a timed test with a few queries to write against given tables. It filters many candidates, so focused preparation pays off.
What the test usually looks like
- Two to five questions, sometimes with a few multiple-choice items.
- A schema of a few tables (customers, orders, products, employees).
- A browser editor where you run queries against hidden test data.
- A time limit, often between 30 and 90 minutes.
Your query is checked against expected output, sometimes on extra hidden data, so it must be correct in general, not just on the sample.
Common question patterns
- Filtering and aggregation: total sales per category for last month.
- Joins: customers with their orders; customers with no orders (LEFT JOIN with IS NULL).
- HAVING: departments with more than five employees.
- Top N per group: top 3 products per category (window functions).
- Second highest value: with DENSE_RANK or a subquery.
- Duplicates: find or remove repeated rows.
- Running totals and month-over-month change: SUM OVER and LAG.
- Date logic: orders per week, users active in consecutive months.
- Conditional counts: CASE WHEN inside SUM or COUNT.
A two-week plan
- Days 1โ3: filtering, sorting, GROUP BY, HAVING, NULL handling.
- Days 4โ6: all join types, including self joins and anti-joins.
- Days 7โ9: subqueries and CTEs.
- Days 10โ12: window functions: ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, running totals.
- Days 13โ14: timed mixed practice under test conditions.
Write every query yourself; reading solutions is not enough.
On the day: time management
- Read all questions first and start with the one you find easiest.
- Look at the schema carefully: column names, data types, which table holds what.
- Write the query in small steps and run often.
- Do not get stuck: move on after a reasonable time and return later.
Mistakes that cost marks
- Wrong join type: INNER JOIN drops customers with no orders.
- NULL handling:
= NULLnever matches; useIS NULL. COUNT(column) skips NULLs. - Ties: "highest salary" may have several people; RANK and DENSE_RANK behave differently.
- Integer division: some databases return whole numbers when dividing integers.
- Output format: wrong column order, missing aliases or unrequested extra columns can fail strict checks.
- Duplicates from joins: joining one-to-many tables can inflate sums.
Check your own answer
Before submitting, ask: what if a customer has no orders? What if two values tie? What if a date falls on the boundary? Edge cases are where hidden tests catch errors.
Practise
Work through our SQL interview questions, then time yourself on the mixed SQL set. Window functions appear often, so drill the ranking set. For theory refreshers, see SQL interview questions for freshers.
Practise what you just read
Reading helps; writing the code yourself is what sticks. Start here: