How to Practise SQL in Your Browser with SQLite and Postgres
Practise SQL joins, grouping and window functions on real SQLite and PostgreSQL engines in the browser, and learn to read query plans and indexes.

How to Practise SQL in Your Browser with SQLite and Postgres
The fastest way to learn SQL is to run a lot of small queries and look at the results. Installing a database server just to practise is a hurdle, and online sandboxes usually send your queries to someone else's machine. WebAssembly changed that: full database engines can now run inside a browser tab. This guide shows how to use that for practice and quick analysis, with the SQL Playground for SQLite and PostgreSQL, and how to read the query plans that explain performance.
Two engines, one sample database
SQLite is the most widely deployed database in the world, embedded in phones, browsers and countless apps. It is a single file with no server. PostgreSQL is a full client-server database known for standards compliance and rich features. Running the same sample data on both shows where SQL is portable and where it differs. Date functions are a classic example: strftime('%Y-%m', placed) in SQLite versus to_char(placed, 'YYYY-MM') in PostgreSQL.
Start with SELECT, WHERE and ORDER BY
Begin by looking at one table: SELECT * FROM customers. Then choose columns, filter with WHERE, sort with ORDER BY and limit rows with LIMIT. Practise combining conditions with AND and OR and use parentheses to make the meaning explicit. Notice how NULL behaves: NULL = NULL is not true, so use IS NULL.
Joins
Joins combine tables through their keys. An inner join keeps only rows that match on both sides; a left join keeps every row from the left table and fills missing matches with NULL. A good exercise is to count orders per customer with a left join and spot customers with zero orders. Always join on keys, and give tables short aliases such as c and o so queries stay readable.
Grouping and aggregates
GROUP BY turns rows into groups and functions such as COUNT, SUM, AVG, MIN and MAX summarise each group. Every selected column must be grouped or aggregated. HAVING filters groups after aggregation, for example customers with revenue above 100. A frequent beginner error is putting an aggregate condition in WHERE; WHERE filters rows before grouping.
Window functions
Window functions compute values across related rows without collapsing them. SUM(...) OVER (ORDER BY month) gives a running total; ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY placed) numbers each customer's orders. They make reports such as "each customer's first order" or "month-over-month change" short and clear, and both SQLite and PostgreSQL support them.
Reading a query plan
When a query is slow, ask the database how it runs it. In SQLite, EXPLAIN QUERY PLAN shows steps such as SCAN orders (reading every row) or SEARCH customers USING INTEGER PRIMARY KEY (a fast lookup). In PostgreSQL, EXPLAIN ANALYZE runs the query and reports each node, such as Seq Scan, Index Scan, Hash Join or Sort, with estimated and actual rows and times. Big differences between estimated and actual rows suggest outdated statistics.
Indexes in practice
Try this experiment: run a query that filters orders by customer_id and look at the plan. Then create an index with CREATE INDEX idx_orders_customer ON orders(customer_id) and explain again. On a large table the plan switches from a scan to a search or index scan. On tiny sample tables the planner may still scan, because reading a few rows is cheaper than using an index. Indexes speed up reads but slow down writes and take space, so add them for real query patterns.
Working with your own data
You can open an existing SQLite file to explore it locally, which is handy for app databases or exported datasets. Export results as CSV for a spreadsheet, JSON for code or INSERT statements to move rows elsewhere. If you change data, download the database file, because an in-browser database lives in memory.
Limits
A browser playground is a single-user, in-memory environment. Reloading resets the data unless you saved the file, PostgreSQL extensions and roles are limited, and large datasets are bound by your device's memory. Query plans on small sample data can differ from plans on production-sized tables, so confirm performance work on realistic data.



