SQL Terminal Simulator
Practice SQL in an interactive browser terminal. Learn SELECT, WHERE, ORDER BY, DISTINCT, aggregates, GROUP BY, HAVING, JOINs, subqueries, and window functions against a small e-commerce schema, with single-table queries evaluated live and verified Postgres output.
Category: Database
What You Will Learn
- Write SELECT queries and project only the columns you need
- Filter rows with WHERE using comparison operators and LIKE
- Sort and cap results with ORDER BY, DESC, and LIMIT
- Summarise data with count, sum, avg, min, max, GROUP BY, and HAVING
- Combine tables with JOINs and keep unmatched rows with LEFT JOIN
- Change data with INSERT, UPDATE, and DELETE and read their command tags
- Compare rows against a subquery and name subqueries with WITH (CTEs)
- Rank rows within groups using window functions
- Test yourself in Challenge mode by writing queries from a plain-English prompt
Topics covered: sql, postgres, postgresql, database, queries, select, joins, aggregates, terminal, backend, educational, interactive
// simulator
SQL Terminal Simulator
Practice SQL in an interactive browser terminal. Learn SELECT, WHERE, ORDER BY, DISTINCT, aggregates, GROUP BY, HAVING, JOINs, subqueries, and window functions against a small e-commerce schema, with single-table queries evaluated live and verified Postgres output.
// sql playground
SQL Terminal Simulator
Practice SQL against a small e-commerce schema in a safe browser terminal. Single-table queries run live; the guided join, subquery, window, and CTE lessons return real Postgres output. Learn SELECT, WHERE, ORDER BY, DISTINCT, aggregates, GROUP BY, HAVING, JOINs, LEFT JOIN, INSERT/UPDATE/DELETE, subqueries, window functions, and CTEs.
4
Tables
50
Rows
13
Lessons
Return every column and row from the customers table.
Welcome to the SQL terminal playground (Postgres-style).
Type "help", run "\dt" to see the tables, or follow the current task above.
customers
- customer_idint
- nametext
- countrytext
- signup_datedate
products
- product_idint
- nametext
- categorytext
- pricenumeric
orders
- order_idint
- customer_idint
- order_datedate
- statustext
order_items
- item_idint
- order_idint
- product_idint
- quantityint
SELECT columns to read
WHERE filters rows
GROUP BY + aggregates summarise
HAVING filters groups
ORDER BY / LIMIT sort and cap
JOIN / LEFT JOIN combine tables
INSERT / UPDATE / DELETE change data
WITH names a subquery (CTE)
About this SQL simulator
What you'll learn
- How SELECT reads rows and how to project specific columns
- How WHERE filters rows with operators like =, <, >, <>, and LIKE
- How ORDER BY, ASC/DESC, and LIMIT shape a result set
- How DISTINCT and the aggregates count, sum, avg, min, and max summarise data
- How GROUP BY buckets rows and HAVING filters those groups
- How JOINs, LEFT JOINs, subqueries, and window functions work across tables
- How INSERT, UPDATE, and DELETE change data, and how CTEs (WITH) name a subquery
Key statements covered
- Read: SELECT, SELECT DISTINCT, column projection, table.column prefixes, AS aliases
- Filter: WHERE with AND/OR, comparison operators, LIKE, and numeric vs string literals
- Aggregate: count, sum, avg, min, max, round, GROUP BY, HAVING
- Shape: ORDER BY, LIMIT
- Relate: JOIN, LEFT JOIN, subqueries, WITH (CTEs), and rank() window functions
- Write: INSERT, UPDATE, DELETE and their psql command tags
How the playground runs your queries
Single-table SELECT queries are evaluated live in your browser against a small e-commerce schema (customers, products, orders, order_items). The guided join, subquery, and window lessons return output captured from a real PostgreSQL instance, so the results you see match what Postgres actually returns. Nothing is sent to a server, so you can experiment freely.
Practice on real Postgres
A simulator is a great place to build intuition, but running these queries against a real database makes them stick. You can spin up a free Postgres in seconds with Neon and paste the same queries in to run them for real, or run managed PostgreSQL on DigitalOcean (new accounts get $200 in credits). Load a table or two, then re-run the lessons here against your own data.
Related reading
Once the queries click, these deep dives cover the schema and query patterns that keep a Postgres database fast as it grows:
- Stop Using Random UUIDs as Primary Keys — why random UUIDs hurt index and primary-key performance, and what to use instead.
- Stop Paginating With OFFSET — how keyset pagination beats LIMIT/OFFSET as tables get large.
Why learn SQL this way?
- SQL clicks fastest when you can change a query and immediately see the rows change.
- The same handful of clauses (SELECT, WHERE, GROUP BY, JOIN) cover most day-to-day queries.
- Reading real result sets builds the instinct you need for reports, debugging, and interviews.
Overview
This SQL simulator is a guided playground for learning queries on a small e-commerce schema with customers, products, orders and order items. The lessons build up in the order most people need them: SELECT basics, filtering with WHERE, sorting and limiting, DISTINCT, counting rows, GROUP BY, HAVING with averages, joining tables, revenue across joins, subqueries and window functions, LEFT JOIN, INSERT, UPDATE and DELETE, and common table expressions. Single-table SELECT queries run live in your browser against the sample data, so you can change a filter or a sort order and see the result immediately. The guided join, subquery and window function lessons return output captured from a real PostgreSQL instance, so their results match what Postgres actually returns. Nothing is sent to a server, so a typo or an unexpected result costs nothing, and a separate challenges mode has eight exercises where you write the queries yourself. The same data also appears as documents in the MongoDB simulator, which makes it easy to compare the two models.
Try this
- Start with "SELECT basics" and change the WHERE clause on the customers table to see the result update in the browser.
- Work through "GROUP BY" and "HAVING and averages" to see the difference between filtering rows and filtering groups.
- Open "LEFT JOIN" and see how customers without pending orders stay in the result with NULL order fields.
Frequently asked questions
- What is the difference between WHERE and HAVING?
- WHERE filters rows before they are grouped, while HAVING filters groups after GROUP BY and can use aggregates such as COUNT or AVG.
- What is the difference between an INNER JOIN and a LEFT JOIN?
- An INNER JOIN returns only rows with a match in both tables. A LEFT JOIN returns every row from the left table and fills the right side with NULL where there is no match.
- What is a common table expression?
- A named subquery defined with WITH at the start of a query. It makes long queries easier to read and lets you refer to the same intermediate result more than once.
Try next
// simulator
PostgreSQL Terminal Simulator
Practice the psql tool and Postgres engine in an interactive browser terminal. Explore with meta-commands, read real EXPLAIN plans, add an index to turn a sequential scan into a bitmap index scan, and use BEGIN and ROLLBACK to make changes safe, all against a small e-commerce database with verified PostgreSQL output.
// simulator
MongoDB Terminal Simulator
Practice MongoDB queries in an interactive browser terminal. Learn find and projections, query operators like $lt, $gt, and $in, sort, skip, limit, countDocuments, insert, update, delete, and the aggregation pipeline with $match, $group, and $sort, against a small e-commerce dataset that runs live in your browser.
// simulator
Database Indexing Simulator
Learn how database indexes work with an interactive simulator. See the difference between full table scans and index seeks, understand B-tree structure, and learn when to create indexes.