Master SQL Queries & Query Optimization
Write and evaluate live SQL queries directly in your browser. Practice relational JOINs, aggregations, subqueries, CTEs, and window functions against pre-populated HR, E-Commerce, and Rideshare schemas.
How to use the SQL playground
Choose a topic or schema, read the table names and columns, and write a query in the workspace. Start with a small SELECT, inspect the rows it returns, then add one JOIN, filter, or aggregate at a time. For example, a LEFT JOIN keeps every row from the left table even when the right side has no match; checking the result after each step makes that row-preserving behavior visible.
The playground runs SQLite compiled to WebAssembly in your browser. Queries use the selected in-memory dataset and are not sent to a database server by this page. It is useful for learning query shape and result sets, but it does not reproduce every behavior or optimizer detail of PostgreSQL, MySQL, or a warehouse engine.
The key lesson is to separate row selection from grouping and window calculations. Practise with JOINs and window functions, then compare the result with the related guides in the learning library.
How to use this tool
Select a schema, inspect its tables, and build a query in small steps. Run the query only after predicting which rows and columns should appear.
Worked example
SELECT department, COUNT(*) AS people FROM employees GROUP BY department ORDER BY department;
Static result: A result table with one row per department and its employee count, ordered alphabetically by department.
Controls
The schema selector loads an in-memory dataset; the editor accepts SQL; Run executes it; the result grid shows rows; Reset restores the sample database.
Honest limits
SQLite runs locally through WebAssembly, so queries are not sent to a database server. SQLite syntax and query plans can differ from PostgreSQL, MySQL, or a warehouse.
Continue with SQL learning guides.
Explore SQL Practice Topics
Beginner SQL
2 TopicsDatabase & SQL Fundamentals
Practice SQL →Master relational database concepts, SQL command pillars (DQL, DDL, DML, DCL), data types, and foundational SQL syntax.
Basic Querying & Filtering
Practice SQL →Master SELECT, WHERE, ORDER BY, LIMIT, DISTINCT, BETWEEN, LIKE, IN, IS NULL, and basic column aliasing.
Intermediate SQL
3 TopicsRelational JOINs
Practice SQL →Combine multi-table datasets using INNER JOIN, LEFT/RIGHT OUTER JOINs, self-joins, and CROSS JOINs.
Aggregations & Group Filtering
Practice SQL →Aggregate datasets using COUNT, SUM, AVG, and filter consolidated data groups using HAVING.
Built-in Functions & CASE WHEN
Practice SQL →Manipulate text, math, and dates with built-in functions, and implement conditional log mappings.
Expert SQL
4 TopicsAdvanced Subqueries
Practice SQL →Leverage scalar, row, correlated and EXISTS nested subqueries to solve complex data comparisons.
CTEs & Set Operators
Practice SQL →Structure temporary query sets with WITH CTEs, and perform operations using UNION, EXCEPT, INTERSECT.
Window Functions
Practice SQL →Perform relative partition operations using ROW_NUMBER, RANK, DENSE_RANK, LAG, and LEAD window frames.
Database Design & Constraints
Practice SQL →Verify normal forms, map key constraints (FK, PK, UNIQUE), and enforce referential check rules.
Scenario-Focused SQL Analytics Playbooks
FAANG Analytics Core
Scenario-focused FAANG SQL Interview playbook covering JOINs, CTEs, and window functions.
Rideshare Logistics
Ride-sharing logistics data metrics, driver payout calculations, and dispatch queries.
Healthcare Auditing
Healthcare audit query patterns, patient appointment timelines, and clinical data metrics.