Home/Blog/SQL

// SQL

LeetCode SQL alternatives for interview practice, compared

Every example on this page was run on 9 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 main LeetCode SQL alternatives are DataLemur, StrataScratch and HackerRank. DataLemur suits data analyst and data scientist interviews, with 54 free SQL questions on 9 Nov 2026. StrataScratch suits data science, machine learning and AI engineering loops that go beyond SQL. HackerRank suits beginners, with 58 short SQL challenges. LeetCode itself had 105 free SQL questions that day, so pick an alternative for the kind of question, not for the count.

What are the best LeetCode SQL alternatives?

The best LeetCode SQL alternative depends on the job you are interviewing for. All three sites below run your query and grade the result, as LeetCode’s Database section does. What differs is the style of question and what comes with it. Each fact in this post was checked on the site’s own page on 9 Nov 2026:

SiteBest forSQL questions freePaid plan
DataLemurData analyst and data scientist interviews54$15 a month or $60 a year
StrataScratchData science, ML and AI engineering loopsPart of 75+ coding questions, plus a free SQL pathFrom $24 a month
HackerRankBeginners and SQL basics58 in its SQL trackFree account
LeetCodeSoftware engineering loops with a SQL round105 of 323Pricing page did not load

Is there a free alternative to LeetCode for SQL?

Yes. DataLemur, StrataScratch and HackerRank all let you practice SQL without paying, but none of them has more free SQL questions than LeetCode. LeetCode’s problem list (checked 9 Nov 2026) held 323 questions in its Database category, and 105 of them were free: 55 Easy, 39 Medium and 11 Hard. LeetCode’s pricing page did not load for us on 9 Nov 2026, so this post states no LeetCode price.

The reason to switch is the style of question, not the number. LeetCode’s SQL questions sit inside a catalog of 4,109 problems, most of them algorithms, and many of its Database questions are puzzles about one table. Data interviews more often ask for a business metric over an events table, which is what the sites below focus on.

Which LeetCode SQL alternative is best for data analyst interviews?

DataLemur is the closest LeetCode SQL alternative for data analyst interviews, because its questions are business metrics modeled on company interviews. On 9 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, which adds the rest of its 100+ SQL questions and 70+ statistics, probability and machine learning questions. What the free tier includes, and a counting mistake it tests, is in Is DataLemur free?.

Which LeetCode SQL alternative is best for data science and AI roles?

StrataScratch is the better LeetCode SQL alternative when the loop also tests Python, statistics, machine learning or a take-home project. StrataScratch’s home page (checked 9 Nov 2026) listed 1000+ coding and concept questions for data science, ML and AI engineering interviews, AI mock interviews, and take-home projects in cloud-hosted Python notebooks.

StrataScratch’s pricing page the same day listed a free plan with no card, 75+ coding questions and its SQL and Python learning paths, which the home page put at 6 modules, 36 lessons and 160+ questions each. The paid plans were $24 a month, $139 a year, or $289 once for lifetime access. A side by side with LeetCode is in StrataScratch vs LeetCode.

Which LeetCode SQL alternative is best for beginners?

HackerRank’s SQL track is the gentlest LeetCode SQL alternative, because most of its challenges test one idea each. HackerRank’s SQL page (checked 9 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 account the same day.

The questions are further from a data interview than DataLemur’s: more filtering and string handling, fewer metrics over event tables. Use HackerRank to get quick at the basics, then move to company-style questions.

Is LeetCode still worth it for SQL?

LeetCode is still worth it for SQL when your interview also has an algorithm round, as many software and data engineering loops do, because one site and one habit then cover both. A data analyst with no algorithm round gets more from a site built around data questions. How LeetCode compares with DataLemur’s alternatives is in DataLemur alternatives.

What kind of SQL question should you be ready for?

Every one of these sites asks for an average over summary rows, and a common wrong answer averages the averages. Here is an original question of that kind: a table holds each day’s order count and revenue, so what is the average order value across all orders? The first attempt averages each day’s revenue per order:

WITH daily(day, orders, revenue) AS (
  VALUES ('2026-11-02', 4, 100), ('2026-11-03', 1, 50), ('2026-11-04', 5, 150)
)
SELECT AVG(revenue / orders) AS avg_order_value
FROM daily;

Output

avg_order_value
35

The three days held 10 orders worth 300 in all, so the average order was worth 30, yet the query says 35. AVG(revenue / orders) gives each day the same weight, so the single order on 3 November counts as much as the four on 2 November. The days’ averages were 25, 50 and 30, and their plain mean is 35.

Divide the total revenue by the total number of orders.

WITH daily(day, orders, revenue) AS (
  VALUES ('2026-11-02', 4, 100), ('2026-11-03', 1, 50), ('2026-11-04', 5, 150)
)
SELECT SUM(revenue) / SUM(orders) AS avg_order_value
FROM daily;

Output

avg_order_value
30

The same trap hides in a conversion rate per campaign or a click-through rate per page: when the groups differ in size, add up the numerators and the denominators first, then divide once. A quick check catches the wrong version: work out the total by hand on a small table and compare. The PostgreSQL manual on aggregate functions defines avg and sum, and the manual on aggregate expressions says what an aggregate receives as input.

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 LeetCode’s, DataLemur’s or StrataScratch’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.

HackerRank SQL vs LeetCode SQL, and whether LeetCode’s SQL 50 study plan is enough for an interview, are separate questions with answers of their own. The best site to practice SQL for interviews in general depends on the role more than on the site, and is answered separately too.