Assessment
SQL Assessment Test
SQL assessment test for hiring: joins, aggregation, window functions and query tuning, with sample questions by level, a scoring rubric and red flags.

The short answer
An sql assessment test for hiring typically runs 30-40 minutes, query writing, query debugging, output prediction, schema design and multiple choice, at 3 difficulty levels. Give it after the first screen and before interviews, and score it on the areas below, fixed before you see any answers, so every candidate is judged the same way.
- SELECT statements, filtering and sorting
- JOIN types (INNER, LEFT, RIGHT, FULL, CROSS) and the grain of the result
- Aggregation (GROUP BY, HAVING, COUNT, SUM, AVG) and conditional aggregation
- Subqueries and common table expressions (CTEs)
Cohesyve tests SQL inside an AI job simulation of the role, after finding and contacting candidates. Ten candidates free, no card.
About to take an SQL test? Practise it free →A SQL assessment test checks whether a candidate can write correct queries against a real schema: filtering, joining and aggregating data, using subqueries, CTEs and window functions, and spotting why a query returns the wrong rows or runs slowly. It is a core screen for data analysts, data engineers, BI developers and backend engineers. The most useful tests give candidates a small schema from your domain and ask questions with a single right answer and a few traps, such as NULLs, duplicates from a join, and ties.
Format
What it measures
- SELECT statements, filtering and sorting
- JOIN types (INNER, LEFT, RIGHT, FULL, CROSS) and the grain of the result
- Aggregation (GROUP BY, HAVING, COUNT, SUM, AVG) and conditional aggregation
- Subqueries and common table expressions (CTEs)
- Window functions (ROW_NUMBER, RANK, LAG, LEAD, running totals)
- NULL handling and three-valued logic
- Data manipulation (INSERT, UPDATE, DELETE) and transactions
- Query performance, indexing and reading an execution plan
Test SQL on the real work
Cohesyve builds an AI job simulation from your job description that covers SQL as the role uses it, finds and contacts candidates, and returns a ranked shortlist. Ten candidates free, no card.
Who takes it
Topics covered
Basic Queries
- SELECT and WHERE clauses
- ORDER BY and row limits (LIMIT, TOP, OFFSET … FETCH)
- String functions
- Date functions
- NULL handling
Joins & Relationships
- Multi-table JOINs
- Self-joins
- Anti-joins (rows with no match)
- Join fan-out and grain
- Many-to-many relationships
Aggregation
- GROUP BY with HAVING
- Multiple aggregations
- Conditional aggregation
- Aggregating before joining
- Running totals
Advanced
- Window functions
- CTEs and recursive queries
- Execution plans
- Index design
- Transactions and isolation
Sample questions
Table orders(id, customer_id, amount, created_at). Return each customer's total spend in 2025, highest first.
BeginnerLook for Filters on a date range (created_at >= '2025-01-01' AND created_at < '2026-01-01') rather than wrapping the column in a function, groups by customer_id, orders by the sum descending.
Why does WHERE manager_id = NULL return no rows, and what should it be?
BeginnerLook for Comparisons with NULL are unknown, not true; use IS NULL. Bonus: knows NOT IN with a NULL in the list returns nothing.
List customers who have never placed an order.
IntermediateLook for LEFT JOIN orders and keep rows where the order id IS NULL, or NOT EXISTS; explains why NOT IN is risky if the subquery can return NULLs.
After joining orders to order_items, revenue per order is far too high. Why, and how do you fix it?
IntermediateLook for Recognises join fan-out: order-level amounts repeated for each item. Aggregates items first or sums at the correct grain, and checks row counts before and after the join.
Return each customer's most recent order, including the amount.
IntermediateLook for ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY created_at DESC) and filter to 1 in a CTE; decides deliberately how to treat ties.
Calculate a 7-day rolling average of daily revenue, including days with no sales.
AdvancedLook for Builds a date spine or calendar table and LEFT JOINs revenue to it, fills gaps with 0, then uses a window frame of ROWS BETWEEN 6 PRECEDING AND CURRENT ROW; explains why missing days would distort the average.
A dashboard query that ran in 2 seconds now takes 3 minutes after the table grew. How do you investigate?
AdvancedLook for Reads the execution plan before changing anything, looks for full scans, functions on indexed columns and fan-out joins, considers an index or pre-aggregation, and verifies the fix with the plan and timings.
Red flags
- Adds SELECT DISTINCT to hide duplicates caused by a bad join
- Uses = NULL or does not know how NULLs behave in comparisons and NOT IN
- Cannot explain the difference between WHERE and HAVING
- Never checks row counts after a join
- Query is right on the sample data but breaks on ties, gaps or NULLs
- Tunes queries by guessing rather than reading the execution plan
Scoring rubric
| Criterion | Weight | What strong looks like |
|---|---|---|
| Correctness | 35% | Right rows, right totals, including NULLs, ties and empty groups. |
| Joins and grain | 20% | Knows the grain of each table and avoids fan-out. |
| Aggregation and window functions | 20% | Chooses GROUP BY or a window function appropriately. |
| Performance awareness | 10% | Writes sargable filters and reads a plan when it matters. |
| Readability and explanation | 15% | CTEs and aliases make the query easy to follow; assumptions stated. |
Why it is used
For employers
- Validate SQL ability before investing interview time
- Assess real query-writing ability, not just definitions
- Compare candidates on the same schema and the same rubric
- Each candidate gets a different variant, so answers cannot be passed around
- See which areas to probe in the technical interview
For candidates
- Demonstrate practical SQL skills beyond resume keywords
- Show what you can do in one timed sitting, without a multi-day take-home project
- Receive a fair evaluation with role-appropriate difficulty
- Differentiate yourself with verified technical skills
Common questions
What is a SQL assessment test?
A SQL assessment test asks a candidate to write, fix or explain queries against a given database schema. Employers use it to check that analysts, data engineers and backend developers can retrieve and combine data correctly before interviews.
How long should a SQL test be?
For screening, 30 to 40 minutes with five to seven questions of rising difficulty works well. That is enough to cover joins, aggregation and one window-function or performance question.
Which SQL dialect should a SQL assessment use?
Use the dialect the role works in. Basic queries look much the same in PostgreSQL, MySQL, SQL Server and Oracle, but the details differ: MySQL has no FULL OUTER JOIN, and SQL Server limits rows with TOP or OFFSET … FETCH instead of LIMIT.
What SQL level should I test for a data analyst versus a data engineer?
Analysts should be strong on joins, aggregation, CTEs and window functions. Data engineers need those plus schema design, performance, transactions and handling incremental or late-arriving data.
Do candidates need access to a database to take the test?
No. The assessment is taken online, with query writing, output prediction and debugging tasks against a provided schema and sample data.
How do I prepare for a SQL assessment test?
Practise joins that return no match, GROUP BY with HAVING, ROW_NUMBER for the latest record per group, and rolling calculations. Always check how your query handles NULLs, duplicates and ties.
Test SQL before the first interview
Cohesyve takes your job description, finds candidates, reaches out to them and tests SQL in an AI job simulation of the real work, then returns a ranked shortlist.
1,500+
assessments completed
50%
faster time-to-hire
5 min
from JD to assessment
No credit card · 10 free candidates · Plans sized to your hiring volume
About to take an SQL test yourself? Practise on an AI job simulation that uses it. 3 free tests, no card.
From the blog