Home / Playground / SQL

Online SQL editor with sample databases

Write SQL and see results instantly on a real SQLite database running in your browser. Start with the online shop or clinic database, see how the tables link, chart any result, check the query plan, or import your own CSV as a table.

Ctrl/⌘ + Enter: run all · Shift + Enter: run the statement at the cursor · Ctrl/⌘ + /: comment · Esc: leave the editor

What you can do here

Which SQL is this?

This is SQLite, the most widely used database engine, compiled to WebAssembly (sql.js). Standard SQL works: SELECT, JOIN, GROUP BY, HAVING, subqueries, CTEs (WITH), window functions (OVER, PARTITION BY, RANK, LAG), INSERT, UPDATE, DELETE and CREATE. A few names differ from PostgreSQL or MySQL: dates use strftime(), text joins with ||.

Is my data saved?

The database lives in your browser's memory. Changes last until you reload the page or switch database. Your query text is saved in this browser, and Share makes a link that contains it.

Examples

ExampleWhat it shows
Your first querySELECT columns FROM a table, filter with WHERE, sort and limit.
Average order value by countryA CTE, two joins and GROUP BY. Press Chart under the result.
Join orders to customersINNER JOIN matches rows on a shared key.
Top 5 products by revenueAggregate, then sort and LIMIT.
Customers with no orders (NULLs)LEFT JOIN keeps rows with no match; the missing side becomes NULL.
Monthly revenueGroup by month with strftime(). Press Chart to draw it.
Running total per customerWindow functions: SUM() OVER and ROW_NUMBER().
Best seller in each categoryRANK() within a PARTITION, then keep rank 1.
Create, insert, update and deleteBuild your own table. Changes last until you reload the page or change database.
No-show rate by waiting timeCASE builds buckets; AVG of a 0/1 column is a rate. Uses the clinic database.

Learn more

Learn the ideas step by step in the free SQL & Databases course: SELECT, joins, grouping, subqueries, window functions and database design.

Questions

Is this SQL practice free?

Yes, with no sign-up. The database runs in your browser.

Is it MySQL, PostgreSQL or SQLite?

SQLite. Almost everything you learn here works the same in MySQL and PostgreSQL; the differences are mostly date and text functions.

Can I practise window functions and CTEs?

Yes. SQLite supports WITH, recursive CTEs and window functions such as ROW_NUMBER, RANK, LAG and running SUM.

Can I use my own data?

Yes. Upload a CSV and it becomes a table you can query.