Practice SQL interview questions
48 real interview-style questions, graded instantly on a real Postgres engine that runs in your browser. Plus a free SQL tutorial, seven sample databases and an online SQL sandbox.
Real Postgres engine
Your query runs on actual Postgres (PGlite) in the browser and is graded column by column, not string-matched.
Interview-shaped
Joins, window functions, CTEs, dates and messy data, the patterns that decide SQL interviews.
No setup
No install, no database server, no signup for the free content. Open a page and run SQL.
Practice SQL by topic
Pick the pattern you want to drill. Every topic page lists its questions with difficulty and the lessons that teach it.
By difficulty
Free SQL practice problems
Start with these free labs. No signup needed.
All users and their plans
List every user's name, email and plan from the users table, ordered by name.
Electronics products
List all products in the Electronics category. Show name and price, cheapest first.
Users from Germany
List the names and plans of all users from Germany, ordered by name.
Product categories
List every distinct product category, alphabetically.
Classic SQL interview questions
Second highest salary
What is the second highest salary in employees? Return it as the only value; if none exists, return NULL.
Top 2 earners per department
Show the top 2 highest paid employees per department: name, department and salary, ordered by department then rank. Salary ties…
Month over month revenue growth
Build a monthly revenue table from completed orders using LAG(). Show month, revenue, prev_revenue and growth_pct rounded to 2…
New users who returned within 7 days
Return the share of users who watched again 1 to 7 days after their first watch, as total_users, returned_users and…
Repeat customers
Show customers with at least 2 completed orders: their name and order count, sorted by count descending then name.
Click-through rate per campaign
For each campaign show name, impressions, clicks and CTR as clicks divided by impressions times 100, rounded to 2 decimals. Order…
Free SQL tutorial
29 short lessons from SELECT to recursive CTEs, each with examples you can edit and run.
- GROUP BY and HAVINGAnswers per category, the heart of analytics.
- SQL cheat sheetEvery clause you need for an interview, on one page, with runnable queries.
- JOINsCombine tables on a key, and watch out for grain.
- Window functionsAggregate without collapsing rows.
- Second highest salaryThe classic interview question, solved three ways.
- Top N per groupGet the best rows in every category with ROW_NUMBER or DENSE_RANK.
Sample databases for SQL practice
Seven realistic schemas you can query for free in the online SQL sandbox.
- Streamflix Video streamingusers, content, watch_events
- CloudCart E-commercecustomers, products, orders, order_items
- AppNest SaaSaccounts, monthly_revenue
- Megalo HRdepartments, employees
- ClickSpark Ad techcampaigns, ad_events
- Fintropolis Bankingcustomers, accounts, transactions
- RideHub Ride sharingdrivers, riders, trips
FAQ
Is the SQL real?
Yes, it runs on a real Postgres engine, so edge cases behave like production.
What is free?
The full SQL tutorial, concept cards, the sandbox, and a handful of preview labs. A license unlocks every practice lab.
Do I need an account?
A license key signs you in and unlocks the Pro labs. Free content works with no signup.
Which formats are covered?
Online screens, take-homes, live coding, and concept cards.