terseql
Play today's puzzle

The daily SQL puzzle where shortest wins

Anyone can write the query.
Can you write it in 57 bytes?

One puzzle a day: a small schema, a plain-English goal, and a real SQLite database running in your browser. Getting it working is the easy part. Your score is the UTF-8 byte length of your query, and the board sorts ascending.

No account. No server round-trip. The engine runs in your tab.

01

A real engine, not a checker

SQLite itself, compiled to WebAssembly, runs in your tab. Hit Run and the actual result table appears. No round-trip, no queue, no waiting to find out you had a typo.

02

Hidden fixtures, so you can't fake it

Your query is graded against seeded databases you never see: empty groups, ties, NULLs, negatives. A query that fits the sample you can see and nothing else fails, exactly as it should.

03

Scored in bytes, ascending

Not points, not stars. The UTF-8 length of your query, counted honestly, so you can't buy a lower score with clever characters. Everyone solves the same puzzle on the same day.

How a round of SQL golf goes

You open the day's puzzle and read two things: a schema of two or three small tables, and one sentence describing the rows you have to return. Say the goal is each customer's total spend, highest first, skipping anyone who never ordered. You write the obvious query, the one you'd put in a pull request. It runs against a real SQLite database in the browser, the result table appears under the editor, and the byte counter reads 126.

That's the starting line, not the finish. Now you start cutting. The alias goes. The AS total goes, because ORDER BY 2 can point at the column by position. JOIN ... ON becomes a comma join and a WHERE clause. Whitespace the parser doesn't need goes. Every cut is one Run to prove you didn't break it, and the counter ticks down: 113, 101, 96. Somewhere below that is a query you haven't thought of yet, and someone else already has.

Submit grades you against fixtures you never see. This is the part that makes the score mean something. It's easy to write a query that happens to produce the right two rows for the sample data on screen, and much harder to write one that also survives a customer with no orders, a refund that drives a total negative, and two customers tied on the same amount. If your query only fits what you can see, Terseql tells you it passed the sample and failed a hidden case, and it doesn't tell you which one. Working that out is the puzzle.

The share card
Terseql 2026-07-16 — Top Spenders

🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦 126
🟦🟦🟦🟦🟦🟦🟦🟦🟦 113
🟦🟦🟦🟦🟦🟦🟦🟦 101
🟩🟩🟩🟩🟩🟩🟩🟩 96

96 bytes (4 cuts)
🔥 4-day streak
https://apps.charliekrug.com/terseql

Your golf trail as a shrinking staircase. It carries no query text, so posting it can't spoil the day for anyone.

Questions

What is SQL code golf?
Writing a query that returns exactly the right rows in as few characters as possible. Correctness is the entry fee; the score is length. Terseql counts UTF-8 bytes, so a multi-byte character costs what it actually costs and you can't buy a lower score with clever glyphs.
Do I need an account?
No. There's no sign-up and no login. Your best byte count and your streak live in your browser's local storage, which also means clearing site data clears your history.
Which SQL dialect does it accept?
SQLite, because that's literally what's running: sql.js is the real SQLite engine compiled to WebAssembly. Window functions, CTEs and GROUP BY ordinals all work. Anything SQLite rejects, Terseql rejects, with the same error message.
Can I break the database?
Go ahead. Every Run gets a fresh copy of the seed data, so DROP TABLE orders costs you nothing but bytes. Grading always uses its own databases, never the one you've been poking at.
Is a new puzzle really posted every day?
Puzzles are keyed to the UTC calendar date, so everyone in the world gets the same one at the same moment and the board compares like with like. Being straight with you: five are authored so far. Writing them is the slow part, because the gap between the obvious query and the short one has to be worth the climb, and the hidden fixtures have to punish exactly the right shortcuts. When the catalogue runs out, the most recent puzzle stays up rather than the page breaking.

Today's puzzle is waiting.

Come back tomorrow for the next one.

Play now →