Learn SQL by writing real queries.
Structured courses, live Postgres sandboxes, and instant auto-grading: everything you need to go from SELECT to window functions with confidence.
- No signup required
- Instant auto-grading
- Progress saves automatically
- courses
- 6
- lessons
- 25
- exercises
- 86
- databases
- 3
Everything you need, from first query to analytics
- SELECT
- WHERE
- ORDER BY
- GROUP BY
- HAVING
- INNER JOIN
- LEFT JOIN
- COUNT(*)
- SUM()
- AVG()
- CASE WHEN
- COALESCE
- IN (…)
- BETWEEN
- LIKE
- WITH … AS
- subqueries
- RANK()
- ROW_NUMBER()
- LAG / LEAD
- PARTITION BY
- running totals
- DISTINCT
- UNION
How it works
Read. Write. Get graded.
The fastest way to build SQL fluency is doing, not watching. Each lesson ends with real exercises.
- Step 01
Read the concept
Short, focused lessons with real examples, written for analysts and engineers, not academics.
Lesson · Aggregations
Grouping rows
GROUP BYcollapses rows that share a value into one row per group. - Step 02
Write real SQL
Execute against live Postgres sandboxes. See real rows, real errors, real timing.
SELECT department_id, COUNT(*) AS headcount FROM employees GROUP BY department_id;sandbox_hr▶ Run - Step 03
Get graded instantly
Auto-grading compares your output to the expected result in milliseconds. Pass and move forward.
Correct. Output matches.
- rows
- 11 / 11
- columns
- 2 / 2
- time
- 4 ms
Try it right here
Run real SQL in 5 seconds.
No account, no setup. Pick a database, tweak a query, and hit run. It executes on live PostgreSQL.
Run it against real PostgreSQL
Edit the query however you like. The sandbox is read-only, so nothing can break.
Curriculum
Six courses. Clear progression.
From your first SELECT to window functions and CTEs, with each course building on the last.
Why it works
Built for real fluency.
Everything around the editor is there to get you unstuck and keep you moving.
The real thing
Real PostgreSQL, not a simulator.
Every query runs on a live database, so you see real rows, real errors and real timing. The sandbox is read-only: nothing you run can break it.
- read-only role
- 3 s timeout
- sandbox_hr
- sandbox_store
- sandbox_hospital
Unstuck fast
Hints that teach
Guided hints step you toward the answer before the solution is ever shown.
- 01Nudge
- 02Approach
- 03Solution
Portable
Five dialects
Learn on Postgres and see how the same idea is written elsewhere.
- PostgreSQL
- MySQL
- SQL Server
- SQLite
- Oracle
Momentum
Streaks & crests
Finish courses to unlock avatar crests, and keep a daily streak going.
- Bronze
- Silver
- Diamond
- Platinum
Look it up
Reference at hand
A full SQL cheat sheet in 13 categories, one click from any editor.
Open the reference
Practice data
Three real sandbox databases
Realistic relational schemas with seeded rows. Switch between them instantly.
HR Database
Enterprise HR schema. Practice aggregations, salary analytics, org hierarchies, and window functions.
sandbox_hrQuery it →
Store Database
Retail e-commerce schema. Revenue rollups, customer segmentation, basket analysis, and inventory queries.
sandbox_storeQuery it →
Hospital Database
Healthcare schema. Appointment funnels, doctor performance dashboards, and patient visit analysis.
sandbox_hospitalQuery it →
FAQ
Questions, answered.
Everything you need to know before writing your first query.
Is LearnWithSQL really free?
Yes, completely free. All courses, exercises, the SQL playground, and the full SQL reference are available without payment. No credit card or signup is required to start practicing.
Do I need to install anything?
No installation needed. LearnWithSQL runs in your browser against real PostgreSQL sandboxes hosted in the cloud. Just open a lesson and start writing queries.
What SQL dialect does LearnWithSQL use?
All exercises execute against real PostgreSQL, not a simulator. The Dialect Switcher in the navbar shows translation tips for MySQL, SQL Server, SQLite, and Oracle when you're learning portable syntax.
Do I need an account to track progress?
No. Progress is saved in your browser automatically. Creating a free account syncs it across devices and unlocks streaks and reward badges, but you can solve every exercise without signing in.
What courses are included?
Six structured courses: SQL Fundamentals, Filtering & Logic, Aggregations, JOINs, Subqueries & CTEs, and Window Functions. Each builds on the last with hands-on exercises against three real sandbox databases (HR, Store, and Hospital).
How is auto-grading done?
When you submit, your query and the reference solution are both executed against the sandbox, and the resulting rows are compared. Exercises use 'exact' matching (order-sensitive) for ORDER BY problems and 'set' matching for non-ordered queries.
Can I run any SQL or only SELECT?
Only SELECT queries are allowed. Queries run under a SELECT-only role with a 3-second timeout. This keeps the sandbox safe and fast for everyone. You can't break or modify the data, but you can practice every real-world read pattern.
Start today · Build real SQL fluency
The SQL skills that get you hired, and promoted.
LearnWithSQL gives you a complete path: structured courses, a free sandbox playground, 86+ graded exercises, and a full SQL reference, all backed by real PostgreSQL.
- No signup required to practice
- Real PostgreSQL, not a simulator
- Auto-graded in milliseconds