Read the data
SELECT picks columns, FROM picks the table, WHERE keeps only matching rows.
SELECT name, salary FROM employees WHERE salary > 50000;
Practice SQL queries in your browser. Build JOIN, GROUP BY and HAVING queries with dropdowns, write your own SQL in a code editor, and run it on a real SQLite database. No signup, no install.
Run a query to see results here.
SELECT picks columns, FROM picks the table, WHERE keeps only matching rows.
SELECT name, salary FROM employees WHERE salary > 50000;
COUNT, SUM and AVG turn many rows into one value. GROUP BY makes the groups, HAVING filters them.
SELECT dept_id, COUNT(*) AS people FROM employees GROUP BY dept_id HAVING COUNT(*) > 1;
CASE WHEN is if / else inside a query. COALESCE fills in a value when something is NULL.
SELECT name,
CASE
WHEN salary >= 50000 THEN 'High'
ELSE 'Low'
END AS band
FROM employees;SQL (Structured Query Language) is the standard language for reading and changing data in databases such as MySQL, PostgreSQL, SQL Server and SQLite. Practising it normally means installing a database first.
This free tool runs a real SQLite database inside your browser tab. Create dummy tables, build a query with dropdowns or write it in a code editor, and see the result instantly. Nothing to install, and nothing you type is uploaded.
Pick a JOIN type and columns. The SQL is written for you.
Highlighting, autocomplete, format and history.
27 runnable examples, from INSERT to window functions.
Join type : INNER Left : employees.dept_id Right : departments.id WHERE : salary > 50000
SELECT * FROM employees INNER JOIN departments ON employees.dept_id = departments.id WHERE salary > 50000;
Every query is a few clauses in a fixed order. Learn the order once and most queries become easy to read.
| Clause | What it does | Example |
|---|---|---|
| SELECT | Choose the columns you want to see | SELECT name, salary |
| FROM | Choose the table to read from | FROM employees |
| JOIN … ON | Combine rows from another table where columns match | JOIN departments ON employees.dept_id = departments.id |
| WHERE | Keep only the rows that match a condition | WHERE salary > 50000 |
| GROUP BY | Make one row per group so you can total it | GROUP BY dept_id |
| HAVING | Keep only the groups that match (WHERE works on rows, HAVING on groups) | HAVING COUNT(*) > 1 |
| ORDER BY | Sort the result | ORDER BY salary DESC |
| LIMIT | Stop after a number of rows | LIMIT 5 |
You write SELECT first, but SQL reads the query in this order: FROM → JOIN → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT. That is why a column alias created in SELECT cannot be used in WHERE.
The functions you will use almost every day. Try any of them in the editor or open them from the Examples tab.
| Function | In one line | Example |
|---|---|---|
| COUNT(*) | Counts rows | COUNT(*) |
| SUM(x) / AVG(x) | Total or average of a column | AVG(salary) |
| MIN(x) / MAX(x) | Smallest or largest value | MAX(salary) |
| ROUND(x, n) | Rounds a number to n decimals | ROUND(salary / 12.0, 2) |
| UPPER(x) / LOWER(x) | Changes the case of text | UPPER(name) |
| LENGTH(x) | Number of characters in text | LENGTH(name) |
| SUBSTR(x, start, len) | Cuts part of a text | SUBSTR(name, 1, 3) |
| x || y | Joins text together | name || ' - ' || city |
| COALESCE(x, y) | Uses y when x is NULL | COALESCE(dept_id, 0) |
| CASE WHEN … THEN … END | If / else logic inside a query | CASE WHEN salary > 50000 THEN 'High' ELSE 'Low' END |
| DATE('now') | Today’s date, with date math | DATE('now', '+7 days') |
| ROW_NUMBER() OVER (…) | Numbers rows inside each group | ROW_NUMBER() OVER (PARTITION BY dept_id ORDER BY salary DESC) |
What each panel and button does, and how to use it.
Builds JOIN, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT queries from dropdowns.
Colours keywords, functions, strings and comments, with line numbers.
Suggests keywords, functions, table names and column names as you type.
Runs the whole editor or only the text you select. Keeps your last 15 queries.
Explains mistakes in plain English and suggests the name you probably meant.
Tidies a query with uppercase keywords and one clause per line. Snippets insert ready templates.
Shows rows with numbers, orange NULLs, row count and run time. The plan shows how SQLite finds the rows.
Load sample data, create tables, import a CSV or export everything as a SQL script.
Five steps from an empty database to a result you understand.
Load a sample dataset, create a table, or import your own CSV. The Tables panel lists each table with its columns.
Use the Visual JOIN builder, or open the SQL editor and write your own. Open any example from the Examples tab.
Press Run, or Ctrl+Enter in the editor. Nothing runs until you do, so you can read and edit first.
Check the rows, the row count and the run time. Open Query plan to see how the database found the rows.
Copy or download the result as CSV or JSON, export the database as SQL, or Reset and try again.
Compare INNER, LEFT, RIGHT and FULL
Change data safely
Totals that pass a test
| JOIN | Keeps | Use it when |
|---|---|---|
| INNER | Only rows that match in both tables | You want employees that have a department |
| LEFT | All left rows, matching right rows or NULL | You want every employee, even without a department |
| RIGHT | All right rows, matching left rows or NULL | You want every department, even empty ones |
| FULL OUTER | All rows from both tables | You want to find rows missing on either side |
| CROSS | Every left row paired with every right row | You need all combinations |
Everything runs in your browser on SQLite (sql.js). Nothing you type is uploaded.
Small time-savers while you write SQL.
| Shortcut | What it does |
|---|---|
| Ctrl/⌘ + Enter | Run the editor, or only the selected text |
| Tab | Accept the first autocomplete suggestion, or insert two spaces |
| Esc, then Tab | Leave the editor with the keyboard (accessibility) |
| Ctrl/⌘ + / | Comment or uncomment the selected lines |
| Enter | New line that keeps the current indent |
| Double-click a table name | Insert the table name into the editor |
Quick answers about the SQL practice playground and editor.
A place to write and run SQL without installing a database. This one runs SQLite in your browser, so you can create tables, run queries and see results straight away.
SQLite. Standard SQL such as SELECT, JOIN, GROUP BY, HAVING, CASE, subqueries, CTEs and window functions works the same as in MySQL or PostgreSQL. A few functions differ, for example dates.
No. The database lives in memory in your browser tab and is cleared when you refresh. Only your recent query history is kept in your browser. Use Export SQL to keep a copy of your tables.
Yes. You are working on a practice database in your own browser, so nothing real can be damaged. Click Reset to get the sample data back.
WHERE filters rows before they are grouped. HAVING filters the groups after GROUP BY, so it can use totals such as COUNT(*) or AVG(salary).
They need a recent SQLite build. If your browser build is older, swap the two tables and use a LEFT JOIN, which gives the same result.
Generate fake rows, then paste the SQL INSERTs into the editor.