// SQL
Best sites to practice SQL for interviews, compared by role
Every example on this page was run on 16 November 2026 in the SQL database on this page, which is close to PostgreSQL, and the output under each one is what it printed. How we test these posts.
The best sites to practice SQL for interviews are DataLemur for data analyst roles, StrataScratch for data science and AI engineering loops, and HackerRank for SQL basics. On 16 Nov 2026, DataLemur had 54 free SQL questions, StrataScratch had a free plan with 75+ coding questions, and HackerRank had 58 SQL challenges on a free account. Pick the site that matches the job you are interviewing for, not the biggest catalog.
What are the best sites to practice SQL for interviews?
The best site to practice SQL for an interview is the one whose questions look like the ones your interviewer will ask. Every site below runs your query and checks the result. Each fact in the table was checked on the site’s own page on 16 Nov 2026:
| Site | Best for | Free SQL practice | Paid plan |
|---|---|---|---|
| DataLemur | Data analyst and data scientist interviews | 54 SQL questions | $15 a month or $60 a year |
| StrataScratch | Data science, ML and AI engineering loops | 75+ coding questions and a SQL learning path | From $24 a month |
| HackerRank | Beginners and SQL basics | 58 SQL challenges | Free account |
LeetCode’s pages refused our requests on 16 Nov 2026, so this post states no LeetCode counts or prices. Its counts from 9 Nov 2026 are in LeetCode SQL alternatives.
Which site is best for data analyst SQL interviews?
DataLemur is the best site for data analyst SQL interviews, because its questions are business metrics modeled on questions from named companies. On 16 Nov 2026, DataLemur’s question list showed 106 questions to a visitor who was not signed in, 54 of them SQL: 21 Easy, 19 Medium and 14 Hard, each with hints and a full solution.
DataLemur’s pricing page listed Premium at $15 a month or $60 a year the same day. Premium adds the rest of its 100+ SQL questions and 70+ statistics, probability and machine learning questions. A $300 package added a coaching call and a signed copy of the founder’s book.
Which site is best for data science and AI engineering interviews?
StrataScratch is the best fit when the interview also tests Python, statistics, machine learning or a take-home project. StrataScratch’s home page (checked 16 Nov 2026) listed 1000+ coding and concept questions, AI mock interviews, interview loops by company and role, and free SQL and Python learning paths of 6 modules, 36 lessons and 160+ questions each.
StrataScratch’s pricing page the same day listed a free plan with no card and 75+ coding questions with solutions. The paid plans were $24 a month, $139 a year, or $289 once for lifetime access, each with a 5-day money-back guarantee. A side by side with LeetCode is in StrataScratch vs LeetCode.
Which site is best if you are new to SQL?
HackerRank’s SQL track is the gentlest place to practice SQL for interviews, because most challenges test one idea. HackerRank’s SQL page (checked 16 Nov 2026) held 58 challenges, 40 Easy, 16 Medium and 2 Hard, grouped as Basic Select, Advanced Select, Aggregation, Basic Join, Advanced Join and Alternative Queries. HackerRank’s home page offered a free developer account the same day.
If you have never written a JOIN, learn first and practice second. SQLBolt (checked 16 Nov 2026) describes itself as interactive lessons and exercises in your browser, running from SELECT queries through joins, aggregates and creating tables. Move to company-style questions once the basics feel quick.
What are the free sites to practice SQL for interviews?
DataLemur, StrataScratch and HackerRank all let you practice SQL for interviews without paying. DataLemur’s 54 free SQL questions are the closest to a data analyst interview. StrataScratch’s free SQL learning path is the most structured. HackerRank’s 58 challenges are free with an account. Use the free tiers for a week before you pay for anything, and pay only for the site whose questions match your interview.
What kind of SQL question should you practice?
Every one of these sites asks some form of “which customers did both things”, and the common wrong answer counts rows instead of distinct values. Here is an original question of that kind: a table holds one row per purchase, so which customers bought both a laptop and a mouse? The first attempt keeps the customers with two matching rows:
WITH purchases(customer, product) AS (
VALUES ('Ava', 'laptop'), ('Ava', 'mouse'), ('Ben', 'laptop'), ('Ben', 'keyboard'),
('Cara', 'mouse'), ('Cara', 'mouse'),
('Dev', 'laptop'), ('Dev', 'mouse'), ('Dev', 'mouse')
)
SELECT customer
FROM purchases
WHERE product IN ('laptop', 'mouse')
GROUP BY customer
HAVING COUNT(*) = 2
ORDER BY customer;
WITH purchases(customer, product) AS (
VALUES ('Ava', 'laptop'), ('Ava', 'mouse'), ('Ben', 'laptop'), ('Ben', 'keyboard'),
('Cara', 'mouse'), ('Cara', 'mouse'),
('Dev', 'laptop'), ('Dev', 'mouse'), ('Dev', 'mouse')
)
SELECT customer
FROM purchases
WHERE product IN ('laptop', 'mouse')
GROUP BY customer
HAVING COUNT(*) = 2
ORDER BY customer;Output
customer Ava Cara
The right answer is Ava and Dev. Cara bought two mice and no laptop, so her two rows pass COUNT(*) = 2. Dev bought a laptop and two mice, and those three rows fail it. COUNT(*) counts purchases, and the question is about kinds of product. Writing WHERE product = 'laptop' AND product = 'mouse' is no better: one row cannot hold both values, so it returns nobody.
Count the distinct products each customer bought from the list, and keep the customers who bought all of them.
WITH purchases(customer, product) AS (
VALUES ('Ava', 'laptop'), ('Ava', 'mouse'), ('Ben', 'laptop'), ('Ben', 'keyboard'),
('Cara', 'mouse'), ('Cara', 'mouse'),
('Dev', 'laptop'), ('Dev', 'mouse'), ('Dev', 'mouse')
)
SELECT customer
FROM purchases
WHERE product IN ('laptop', 'mouse')
GROUP BY customer
HAVING COUNT(DISTINCT product) = 2
ORDER BY customer;
WITH purchases(customer, product) AS (
VALUES ('Ava', 'laptop'), ('Ava', 'mouse'), ('Ben', 'laptop'), ('Ben', 'keyboard'),
('Cara', 'mouse'), ('Cara', 'mouse'),
('Dev', 'laptop'), ('Dev', 'mouse'), ('Dev', 'mouse')
)
SELECT customer
FROM purchases
WHERE product IN ('laptop', 'mouse')
GROUP BY customer
HAVING COUNT(DISTINCT product) = 2
ORDER BY customer;Output
customer Ava Dev
The number after = is the length of the IN list, so the same query answers “bought all three” or “used every feature”. Before you submit on any site, add a customer with a repeated row to your test data and check the answer by hand. The same GROUP BY and HAVING pattern finds repeats in Find duplicate rows in SQL. The PostgreSQL manual on aggregate functions defines count, and the PostgreSQL SELECT reference covers GROUP BY and HAVING.
Where else can you practice SQL for interviews?
Prepshotz is free during its beta, with no credit card, and grades each SQL query by running it against a real database, with hints and feedback built around your output. Its catalog is much smaller than DataLemur’s, StrataScratch’s or HackerRank’s, and each account can build 5 goal-built tracks during the beta. The SQL interview practice guide has a study plan, and the comparison page sets LeetCode, DataLemur and Prepshotz side by side.
Related questions
DataLemur vs StrataScratch, HackerRank SQL vs LeetCode SQL, and whether StrataScratch is free are separate questions with answers of their own. Whether LeetCode’s SQL 50 study plan is enough for an interview is answered separately too.