Query real tables. Compare the rows. Refine your answer.
Join deployments to services by service_id = services.id. Return only deployments whose environment is exactly "production" and whose matching service has active = 1. A NULL service_id has no matching service and must be excluded. Return deployments.id as deployment_id, services.name as service_name, and deployments.deployed_at as deployed_at, in that order. Sort deployed_at descending, then deployment_id ascending. Timestamps are UTC text in YYYY-MM-DD HH:MM:SS format. Do not merge separate deployments when service names repeat.
CREATE TABLE services ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, active INTEGER NOT NULL CHECK (active IN (0, 1)));CREATE TABLE deployments ( id INTEGER PRIMARY KEY, service_id INTEGER REFERENCES services(id), environment TEXT NOT NULL, deployed_at TEXT NOT NULL); | id | service_id | environment | deployed_at |
|---|---|---|---|
| 101 | 1 | production | 2026-09-01 10:00:00 |
| 102 | 2 | production | 2026-09-04 10:00:00 |
| 103 | 1 | staging | 2026-09-04 11:00:00 |
| 104 | 3 | production | 2026-09-03 10:00:00 |
| 105 | Missing value: NULL | production | 2026-09-05 10:00:00 |
| id | name | active |
|---|---|---|
| 1 | api | 1 |
| 2 | worker | 0 |
| 3 | admin | 1 |
| deployment_id | service_name | deployed_at |
|---|---|---|
| 104 | admin | 2026-09-03 10:00:00 |
| 101 | api | 2026-09-01 10:00:00 |
| id | service_id | environment | deployed_at |
|---|---|---|---|
| 2 | 1 | production | 2026-09-02 12:00:00 |
| 5 | 2 | production | 2026-09-02 12:00:00 |
| id | name | active |
|---|---|---|
| 1 | api | 1 |
| 2 | api | 1 |
| deployment_id | service_name | deployed_at |
|---|---|---|
| 2 | api | 2026-09-02 12:00:00 |
| 5 | api | 2026-09-02 12:00:00 |
| id | service_id | environment | deployed_at |
|---|---|---|---|
| 1 | 1 | staging | 2026-09-01 00:00:00 |
| id | name | active |
|---|---|---|
| 1 | api | 1 |
| deployment_id | service_name | deployed_at |
|---|
0 rows
| id | service_id | environment | deployed_at |
|---|
0 rows
| id | name | active |
|---|
0 rows
| deployment_id | service_name | deployed_at |
|---|
0 rows
SQLite runs in your browser using sample tables that reset for every test. Write one read-only SELECT or WITH query. Runs stop after about eight seconds. Results compare column names, typed values, and row order. SQLite engine credits. Test results support self-study and don’t certify proficiency.