Skip to content
← All Assessments
Skills

SQL Skills Test for Hiring

Verify SQL proficiency with practical challenges — from basic SELECT queries to complex JOINs, window functions, and query optimization.

What It Measures

## What This SQL Skills Assessment Covers The assessment can cover query construction, joins, filtering and aggregation, null handling, common table expressions, window functions, indexing concepts, execution-plan reasoning, transactions, and data-model trade-offs. Select only the topics required by the role; an analyst, application engineer, and database specialist may need different evidence. Questions should test correct reasoning about realistic data tasks rather than memorized trivia. A multiple-choice result cannot demonstrate every aspect of production database work, so use a representative work sample or structured technical discussion where deeper implementation evidence is needed.

How It Works

## How It Works The hiring team selects the SQL skills, question count, question-level timing, and passing score. The approved questions and keyed answers are reused for comparable candidates, and HeyHRM reports score percentage and performance by skill. Scoring does not automatically recalibrate a candidate as an analyst, engineer, or database administrator. Match the selected content and interpretation to the role before launch, then use the result to guide consistent follow-up.

Sample Questions

1. You need to retrieve each customer's total order amount and their rank within their country by total spending. You must include customers with zero orders. Which query is most efficient?

  • A.SELECT c.id, c.name, COALESCE(SUM(o.amount), 0) as total, RANK() OVER (PARTITION BY c.country ORDER BY SUM(o.amount) DESC) as rank FROM customers c LEFT JOIN orders o ON c.id = o.customer_id GROUP BY c.id, c.name, c.country ORDER BY c.country, rank
  • B.SELECT c.id, c.name, SUM(o.amount) as total, RANK() OVER (PARTITION BY c.country ORDER BY total DESC) as rank FROM customers c FULL OUTER JOIN orders o ON c.id = o.customer_id GROUP BY c.id, c.name, c.country
  • C.SELECT c.id, c.name, (SELECT SUM(amount) FROM orders WHERE customer_id = c.id) as total, RANK() OVER (PARTITION BY c.country ORDER BY (SELECT SUM(amount) FROM orders WHERE customer_id = c.id) DESC) FROM customers c
  • D.SELECT c.id, c.name, COALESCE(o.total, 0), RANK() OVER (ORDER BY o.total DESC) FROM customers c LEFT JOIN (SELECT customer_id, SUM(amount) as total FROM orders GROUP BY customer_id) o ON c.id = o.customer_id

2. What does this query output for the 2nd row of each product_id? SELECT product_id, price, LAG(price, 1) OVER (PARTITION BY product_id ORDER BY date) as prev_price FROM price_history

  • A.NULL, because there is no previous row for the 2nd row in each partition
  • B.The price from the 1st row of that product_id
  • C.The difference between current and previous price
  • D.An error, because LAG cannot be used with PARTITION BY

3. When should you use a subquery in the FROM clause (derived table) versus a CTE (WITH clause)? Select the best answer.

  • A.Always use CTEs; they're universally more efficient
  • B.Use subqueries for single-use logic; CTEs for reused logic or readability, though some databases treat them identically
  • C.Subqueries are always faster because they execute inline
  • D.CTEs cannot handle complex aggregations that subqueries can

4. Your query: SELECT category, COUNT(*) as count FROM products WHERE price > 100 GROUP BY category HAVING COUNT(*) > 5 returns categories with 5+ expensive products. Why is this approach better than filtering with WHERE COUNT(*) > 5?

  • A.WHERE cannot reference aggregates; HAVING can. HAVING filters groups after aggregation, while WHERE filters rows before
  • B.There is no difference; WHERE and HAVING are interchangeable
  • C.WHERE is more efficient and should always be preferred
  • D.HAVING is only for advanced SQL; beginners should use WHERE

5. You have a frequently-run query: SELECT * FROM transactions WHERE user_id = 1 AND created_date > '2025-01-01'. The table has 100M rows. Which index strategy is best?

  • A.Composite index on (user_id, created_date) in that order
  • B.Separate indexes on user_id and created_date; the optimizer will use both
  • C.A covering index including all columns in SELECT *
  • D.No index; full table scans are faster on modern hardware

6. A column contains NULL values. Your query: SELECT * FROM users WHERE status != 'active' returns 50 rows, but you expect 5000 rows (all non-active users). What's the issue?

  • A.NULL values are not equal to any value, including when using !=. Use WHERE status != 'active' OR status IS NULL to include NULLs
  • B.The query is correct; the data is incomplete
  • C.You need to use status <> 'active' instead of !=
  • D.NULL values cause the query to error, which is why fewer rows return

Frequently Asked Questions

Is this assessment testing database-specific syntax (MySQL, PostgreSQL, SQL Server)?▾
This assessment focuses on ANSI SQL standards that work across all major databases (PostgreSQL, MySQL, SQL Server, Oracle). Some advanced questions mention database-specific optimization considerations, but core concepts are universal. Your performance reflects portable SQL knowledge.
Do I need to memorize SQL functions?▾
No. This assessment tests conceptual understanding—knowing when to use window functions, understanding JOIN types, recognizing optimization opportunities. You're not expected to memorize function syntax. The focus is on SQL problem-solving and database reasoning.
What if I'm strong in SQL but weak in NoSQL databases?▾
This assessment focuses on selected SQL skills. Verify the current catalog and use a separate, job-relevant method if the role also requires NoSQL evidence.
How is SQL proficiency different from database administration?▾
SQL is query construction and optimization—writing and tuning statements to solve data problems. Database administration includes backup strategies, user permissions, infrastructure, and system-level management. Strong SQL is necessary for DBAs but insufficient alone. This assessment isolates query and optimization skills.
Why are window functions weighted so heavily?▾
There is no fixed product weighting for window functions. The hiring team should select and interpret SQL topics according to the role's essential duties.
Is query performance relevant for entry-level positions?▾
A job-related assessment may add useful evidence, but it cannot guarantee future performance or hiring outcomes. Validate it for the specific role and purpose, monitor outcomes and adverse impact, and combine it with other structured evidence.
What if I've only used an ORM like Hibernate or Django?▾
ORMs abstract SQL, but generated queries often perform poorly. Strong SQL knowledge helps you optimize ORM-generated queries and recognize when direct SQL is necessary. This assessment tests SQL fundamentals—essential background whether you use ORMs or write SQL directly.
How do NULL values affect aggregation?▾
NULL values are excluded from aggregate functions (COUNT, SUM, AVG, etc.). COUNT(*) counts all rows; COUNT(column) counts only non-NULL values. Understanding this prevents subtle bugs where aggregations seem to undercount. Proper NULL handling in GROUP BY and JOINs is a SQL literacy marker.
Should I optimize for readability or performance?▾
A job-related assessment may add useful evidence, but it cannot guarantee future performance or hiring outcomes. Validate it for the specific role and purpose, monitor outcomes and adverse impact, and combine it with other structured evidence.
How does this assessment compare to other SQL tests?▾
Compare current products directly on job relevance, question and scoring controls, accessibility, validation evidence, security, candidate experience, integrations, and total cost. Verify vendor-specific details from current documentation.

Ready to assess candidates?

Start screening with SQL Skills Test today. Free to get started.

Get Started Free

Related Assessments

Browse All Assessments →

From the Blog