Every question runs your query on the visible sample data and on at least two hidden datasets built to catch common mistakes: ties, NULLs, empty groups, duplicate rows and dates on the edge of a range. Your answer passes when it returns the right result on all of them.
We compare results, not query text. Any query that returns the right rows passes, however it is written.
The rules below are the whole grader. Each one is covered by an automated test (tests/grader.test.ts), and every question in the bank is checked against them with a reference solution, at least two other correct solutions and at least three known-wrong queries.
1. Rows are compared as a set, duplicates included
Row order does not matter unless the question asks for a sort (rule 9). Duplicates count: if the answer has a row twice, yours must have it twice. A missing row and an extra row are both listed under your result, so you can see exactly what differs.
2. The number of columns must match
If the question asks for three columns, return three. A missing or extra column fails, and the message names the columns the answer has.
3. Column names are not graded
Columns are matched by position first. If your columns come in another order, they are matched by name, and failing that by their values. A note tells you when your names or column order differ from the question, because a human interviewer will notice.
4. Numbers compare as numbers
3, 3.0 and 3.000 are equal, whether the column is an integer, a numeric or a float. Tiny float noise (a relative difference under 0.0000001%) is ignored. Integer division is not: 0 is not 0.5.
5. Rounding
When a question asks for a number of decimal places:
- A value rounded as asked passes.
- An unrounded value that rounds to the answer passes, with a note. Most auto-graded screens would mark it wrong, so round in a real test.
- A value one unit off in the last decimal place passes, with a note. This happens when a half is rounded another way: Postgres rounds a numeric 2.5 to 3 and a float 2.5 to 2. Cast to numeric before
ROUNDto match exactly.
When a question asks for rounding on some columns only (say a share to 1 place next to money in cents), the allowance applies to those columns and the others must match exactly.
When a question does not mention rounding, no rounding allowance applies.
6. NULL matches only NULL
An empty string, 0 or the text 'NULL' is not NULL.
7. Text is exact
Case and spaces matter: Paris, paris and Paris are three different values. Labels you compute yourself (for example with CASE) must use the exact words the question gives.
8. Dates, timestamps and months
- A date equals the same day at midnight as a timestamp:
2025-03-01and2025-03-01 00:00:00match. - Dates and timestamps also match their ISO text, so
to_char(day, 'YYYY-MM-DD')is fine. - A month written as
2025-03equals the first day of that month,2025-03-01, so a month fromdate_trunc('month', ...)and one fromto_char(..., 'YYYY-MM')both pass. - Booleans equal the text
trueandfalse.
All times in the practice data are UTC.
9. Sort order, only when asked
If the question says how to sort, your rows must come in that order, checked only on the columns it names. Rows that tie on every named column may come in any order. NULLs may sort first or last. Text sorts by byte order, as Postgres does with the C collation (capital letters before lower case).
10. Empty answers
Some hidden datasets have no qualifying rows. Then the right answer is an empty result with the right columns.
11. Size limit
Results over 5,000 rows are not graded. No answer in the bank is longer than 400 rows, so a result that big means a join is multiplying rows.
Where your query runs
Queries run in PostgreSQL 19 compiled to WebAssembly, inside your browser. Nothing is sent to a server. Each query runs in a read-only transaction that is rolled back, so you cannot change the data, and one statement runs at a time. A query that runs longer than 8 seconds is stopped.