blackdroid.dev

SQL Practice

Practice SQL with instant feedback — 8 exercises from SELECT basics to window functions, checked against a real DuckDB engine in your browser. Free, no signup.

Select + filter

List the name and salary of employees in department 1 (Engineering), any order.

Sample schema (employees · departments · orders)
CREATE TABLE departments (id INT, name VARCHAR);
INSERT INTO departments VALUES (1,'Engineering'),(2,'Sales'),(3,'HR'),(4,'Marketing');
CREATE TABLE employees (
  id INT, name VARCHAR, dept_id INT, salary INT, hired DATE
);
INSERT INTO employees VALUES
  (1,'Ada',1,95000,'2019-03-01'),(2,'Grace',1,88000,'2020-07-15'),
  (3,'Linus',1,91000,'2021-01-10'),(4,'Margaret',2,72000,'2018-11-20'),
  (5,'Alan',3,68000,'2022-05-05'),(6,'Edsger',2,78000,'2019-09-30'),
  (7,'Barbara',4,70000,'2023-02-14'),(8,'Donald',1,102000,'2017-06-01');
CREATE TABLE orders (
  id INT, employee_id INT, amount DECIMAL(10,2), status VARCHAR, created DATE
);
INSERT INTO orders VALUES
  (1,4,1500.00,'done','2024-01-05'),(2,4,2300.50,'done','2024-01-12'),
  (3,6,800.00,'pending','2024-02-01'),(4,2,5600.00,'done','2024-02-14'),
  (5,2,1200.00,'cancelled','2024-03-01'),(6,8,990.00,'done','2024-03-15'),
  (7,4,4100.25,'done','2024-03-20'),(8,1,340.00,'pending','2024-04-02');
Hint
SELECT name, salary FROM employees WHERE dept_id = 1

About SQL Practice

Eight hands-on SQL exercises on a small employees/departments/orders dataset — from SELECT filtering through JOINs and aggregates up to CASE expressions and window functions. Your query runs against a real DuckDB engine in your browser and the result is compared to the reference answer row-for-row (order-insensitive), so you get an instant correct/incorrect verdict plus your actual output table.

Each exercise includes the full sample schema, a hint, and a solution you can reveal when stuck. Everything runs locally via WebAssembly — no account, no progress tracking, and your queries never leave the machine. Solved exercises are marked in the sidebar for the session.

How to use SQL Practice

  1. Pick an exercise from the list (easy → hard) and read the task plus the sample schema.
  2. Write your SELECT and hit Run & check — your result table appears and is compared to the expected answer.
  3. Stuck? Expand the hint, or reveal the solution to see the reference query.

Frequently asked questions

How is my answer checked?

Your query and the reference solution both run against the same in-browser DuckDB dataset; the row sets are compared with symmetric EXCEPT ALL, so different-but-equivalent queries pass as long as the output rows match (order-insensitive).

Do I need to know DuckDB dialect?

The exercises use standard SQL that works in PostgreSQL, MySQL and SQLite too. DuckDB-specific features aren't required.

Is anything uploaded?

No — the engine runs via WebAssembly in your browser; queries and data never leave the device.