Choose & filter
SELECT name, city FROM customers WHERE city = 'London' ORDER BY name;
WHERE filters rows. Use AND / OR and parentheses to combine conditions.
Subjects / SQL playground
The query dojo
Become the analyst at Dojo Insurance. Explore the records, connect customers to their policies and trace every claim.
Device storage is unavailable. You can still use the lab; your changes and progress will last for this visit.
Getting started
Each question uses fresh starting records. Return the requested columns in the stated order; aliases are your choice.
Try a query
Use a single statement. Text goes in single quotes. Table and column names are not case sensitive.
Write a query above, then run it to see the result here.
A little help at your desk
SELECT name, city FROM customers WHERE city = 'London' ORDER BY name;
WHERE filters rows. Use AND / OR and parentheses to combine conditions.
SELECT c.name, p.policy_type FROM customers c JOIN policies p ON c.customer_id = p.customer_id;
JOIN keeps matching rows. LEFT JOIN also keeps unmatched rows from the first table.
SELECT status, COUNT(*) AS total FROM claims GROUP BY status HAVING COUNT(*) > 2;
GROUP BY gathers rows. HAVING filters groups. COUNT(column) ignores NULL; COUNT(*) counts rows.
SELECT, DISTINCT, table and column aliases, INNER JOIN, LEFT JOIN, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT and OFFSET. Conditions include =, !=, <>, <, >, <=, >=, AND, OR, NOT, IS NULL, IS NOT NULL, IN, BETWEEN and LIKE (% and _). Arithmetic supports +, −, *, / and %. Aggregates: COUNT, SUM, AVG, MIN and MAX. Other functions: ROUND, LOWER, UPPER, LENGTH, COALESCE and ABS.
Sandbox also supports INSERT INTO with a column list and VALUES, UPDATE ... SET, and DELETE FROM. Primary keys must be unique; foreign keys must reference existing rows. All provided columns are required. Failed changes leave all tables unchanged.
This is a small JavaScript emulator, not a full SQL dialect. It does not support subqueries, UNION, RIGHT/FULL/CROSS JOIN, CREATE/DROP/ALTER, date functions, transactions or quoted identifiers. Dates are text in YYYY-MM-DD format. Text comparisons are case sensitive; LIKE ignores case. Use a decimal point for decimal numbers. Results display up to 200 rows, and each table holds up to 200 records. Queries have a work limit to keep the lab responsive.