// SQL
StrataScratch vs LeetCode: which to use for SQL interviews
Every example on this page was run on 19 October 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.
StrataScratch vs LeetCode comes down to the job you are interviewing for. StrataScratch is built for data science, machine learning and AI engineering interviews, with SQL, Python, statistics and take-home projects. LeetCode is built for software engineering interviews, with thousands of algorithm problems and a Database section of 323 SQL questions, 105 of them free on 19 Oct 2026. Pick StrataScratch for a data role and LeetCode for a coding loop.
Is StrataScratch or LeetCode better for SQL interviews?
StrataScratch is the better fit when SQL is the main round of a data analyst, data scientist or analytics engineer interview, because its whole catalog is about data work. LeetCode is the better fit when SQL is one round among algorithm rounds, as in many software engineering loops, because one account and one habit then covers both. The SQL skills tested are much the same either way: joins, grouping and window functions over small tables.
How many SQL questions does LeetCode have?
LeetCode’s Database category held 323 SQL questions on 19 Oct 2026, and 105 of them were free (counted from LeetCode’s problem list, checked 19 Oct 2026). The rest are marked for paid subscribers only. The split by difficulty:
| Difficulty | Free | Paid only |
|---|---|---|
| Easy | 55 | 58 |
| Medium | 39 | 105 |
| Hard | 11 | 55 |
The whole LeetCode problem list held 4,086 problems that day, so SQL is under a tenth of the catalog. Most of LeetCode is algorithms and data structures in general purpose languages.
What does StrataScratch cover besides SQL?
StrataScratch covers the parts of a data interview that are not SQL. StrataScratch’s home page (checked 19 Oct 2026) listed 1000+ coding and concept questions for data science, ML and AI engineering interviews, covering SQL, Python, ML system design and statistics. It also listed AI mock interviews for data scientist, ML engineer and AI engineer roles, and take-home projects in cloud-hosted Python notebooks, with 60+ tagged for AI and ML roles.
For beginners, the same page listed free learning paths for SQL and for Python, each with 6 modules, 36 lessons and 160+ questions, from foundations to window functions. StrataScratch’s menu also has an Algorithm section, but algorithm depth is LeetCode’s strength.
Are StrataScratch and LeetCode free?
Both start free and both sell a paid plan. StrataScratch’s home page said “Start Coding Free” and “No credit card required” on 19 Oct 2026. On LeetCode, about a third of the SQL questions were free, as counted above. Neither pricing page loaded for us on 19 Oct 2026, so this post states no prices: read them on StrataScratch’s and LeetCode’s own sites before you pay.
Which should you use for a data science interview?
Use StrataScratch first for a data science or analyst interview, then add LeetCode’s free SQL questions if you run out. A data science loop often includes Python data work, statistics and a take-home, and StrataScratch has all three. A software engineer or data engineer whose loop includes an algorithm round should do the reverse: LeetCode first, and StrataScratch for extra SQL practice.
What kind of SQL question should you be ready for?
Data interview SQL questions often ask for a business metric over an events table, and a common wrong answer counts rows when the question asks for people. Here is an original question of that kind: how many different users were active on each day? The first attempt counts every event:
WITH events(user_id, day) AS (
VALUES (1, '2026-10-01'), (1, '2026-10-01'), (2, '2026-10-01'),
(1, '2026-10-02'), (3, '2026-10-02'), (3, '2026-10-02'), (3, '2026-10-02')
)
SELECT day, COUNT(*) AS active_users
FROM events
GROUP BY day
ORDER BY day;
WITH events(user_id, day) AS (
VALUES (1, '2026-10-01'), (1, '2026-10-01'), (2, '2026-10-01'),
(1, '2026-10-02'), (3, '2026-10-02'), (3, '2026-10-02'), (3, '2026-10-02')
)
SELECT day, COUNT(*) AS active_users
FROM events
GROUP BY day
ORDER BY day;Output
| day | active_users |
|---|---|
| 2026-10-01 | 3 |
| 2026-10-02 | 4 |
Only two users were active on each day, yet the query says three and four. COUNT(*) counts rows, and user 1 has two events on the first day while user 3 has three on the second. Count each user once with COUNT(DISTINCT user_id):
Use COUNT(DISTINCT user_id) when the question asks how many users, not how many events.
WITH events(user_id, day) AS (
VALUES (1, '2026-10-01'), (1, '2026-10-01'), (2, '2026-10-01'),
(1, '2026-10-02'), (3, '2026-10-02'), (3, '2026-10-02'), (3, '2026-10-02')
)
SELECT day, COUNT(DISTINCT user_id) AS active_users
FROM events
GROUP BY day
ORDER BY day;
WITH events(user_id, day) AS (
VALUES (1, '2026-10-01'), (1, '2026-10-01'), (2, '2026-10-01'),
(1, '2026-10-02'), (3, '2026-10-02'), (3, '2026-10-02'), (3, '2026-10-02')
)
SELECT day, COUNT(DISTINCT user_id) AS active_users
FROM events
GROUP BY day
ORDER BY day;Output
| day | active_users |
|---|---|
| 2026-10-01 | 2 |
| 2026-10-02 | 2 |
A grader compares the whole result, so the first query fails on every row. The PostgreSQL manual on aggregate expressions defines count(DISTINCT expression), and the manual on aggregate functions lists count(*) as the count of input rows. Another counting mistake, COUNT(*) after a LEFT JOIN, is in the DataLemur post, and ties in ranking questions are in second highest salary in SQL.
Where else can you practice SQL interview questions?
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 StrataScratch’s or LeetCode’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, 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 depends on the role, and is answered separately too.