Course

SQL interview practice on PostgreSQL

Write real queries against a real PostgreSQL 18 database. Your results are compared row by row with hidden datasets built to catch the classic mistakes.

  • 3 topics
  • 11 skills
  • 44 lessons
  • 156 practice questions
  • 37 SQL problems

What you'll learn

Three topics take you from SQL fundamentals (filtering, joins, aggregation, subqueries and set operations) through analytical SQL (ranking and running-total window functions, recursive CTEs, time series, gaps and islands) to SQL for backend engineers: schema design and constraints, safe writes with upserts and transactions, indexes and query plans, and JSON in PostgreSQL.

Each problem shows you the schema and a sample dataset. Submit runs your SQL against hidden datasets with the traps interviewers love: NULLs in NOT IN, ties, an empty group, a timestamp at midnight. Tuning labs go further: the rows must be right and the query plan's estimated cost must come close to the reference solution's.

The curriculum

Every skill has a lesson, a staff-level deep dive, a quick revise page and practice questions. Click a skill to read its lesson free.

SQL Fundamentals

3 skills

Selecting, filtering, joining and grouping rows - and the NULL, duplicate and fan-out rules that decide whether a query that runs is a query that's right.

Analytical SQL

4 skills

Window functions, CTEs and recursive queries, and time series - top-N per group, running totals, period-over-period change, retention and streaks, the questions data-heavy interviews and dashboards ask.

SQL for Backend Engineers

4 skills

Designing tables the database can defend, changing them on live data, writing safely under concurrency with upserts, MERGE and transactions, making queries fast with the right index, and storing JSON without losing SQL.

Every SQL problem

Easy SQL problems

  • Create the Accounts TableFree
  • Customers Who Never OrderedFree
  • Daily Signups, Quiet Days IncludedFree
  • Departments Paid Above the Company AverageFree
  • Large Card Payments From WebhooksFree
  • Orders Placed in JanuaryFree
  • Products Above Their Category AverageFree
  • Revenue by CountryFree
  • Second Highest SalaryFree
  • The Report That Runs a Query per CustomerFree

Medium SQL problems

  • Bought Coffee, Never GearPro
  • Cancellation Rate per CustomerPro
  • Daily Active Users in New York TimePro
  • Everyone Under a ManagerPro
  • Flatten Order Line ItemsPro
  • Foreign Keys Without IndexesPro
  • Index the Order History PagePro
  • Make the Daily Report Use Its IndexPro
  • One Active Subscription per CustomerPro
  • Paid Orders per CustomerPro
  • Running Balance per AccountPro
  • The Support Dashboard Reads Every OrderPro
  • Top Two Products per CategoryPro
  • Transfer Money Without OverdrawingPro
  • Upsert Daily Product StatsPro
  • Week-One Retention by Signup DayPro

Hard SQL problems

  • Category Tree TotalsPro
  • Country Sales Without Double CountingPro
  • Customer Documents for the APIPro
  • Customers Making 80% of RevenuePro
  • Keep the Latest Signup per EmailPro
  • Keyset Pagination for the Activity FeedPro
  • Longest Login StreakPro
  • Merge Leads From Two ListsPro
  • Month-over-Month Revenue ChangePro
  • Normalize Comma-Separated TagsPro
  • Sync the Catalog With a Supplier FeedPro

Questions

Which SQL dialect does AI Proof Engineers use?

PostgreSQL 18. Nearly everything carries over to MySQL, SQL Server and other databases, and the lessons point out where PostgreSQL behaves differently.

Is this for data interviews or backend interviews?

Both. The first two topics cover the querying and analytics data interviews test. The third covers what backend interviews ask about: schema design, transactions, indexes and query plans.

How are query-tuning labs graded?

Your query must return the right rows, and PostgreSQL's estimated cost for it must be within a set ratio of the reference's. The lab tables are fixed, so the cost is the same every time you run it, unlike timings.

What's free in the SQL course?

All 44 SQL lessons and 156 practice questions, plus the 10 easy problems. Pro unlocks the other 27, including the tuning labs.

Start the SQL practice course free

No card needed. Upgrade to Pro when you want the full problem bank.

Free plan, no card · 7-day Pro trial · Cancel anytime