{"id":"code-hs-sql-club-members-query","audience":"high-school","category":"coding","track":"coding","technique":"context","title":"Write a SQL query for your club's sign-in app","free":false,"task":"You're building the chess club's sign-in app and need the list of members who can play in Saturday's tournament: joined this school year (joined_on on or after 2026-08-15), paid dues (dues_paid = 1) and haven't left (left_on is NULL). Columns exactly first_name and last_name, sorted by last_name then first_name. Write one SQLite query in exactly 1 code block of at most 8 lines, under 30 words of text.","materialLabel":"Your club's table (attached to your prompt automatically)","material":"-- club.db  (SQLite) - Lincoln High Chess Club sign-in app (my CS project)\n\nCREATE TABLE members (\n  id          INTEGER PRIMARY KEY,\n  first_name  TEXT NOT NULL,\n  last_name   TEXT NOT NULL,\n  grade       INTEGER NOT NULL,      -- 9 to 12\n  joined_on   TEXT NOT NULL,         -- 'YYYY-MM-DD'\n  dues_paid   INTEGER NOT NULL,      -- 1 = paid, 0 = not paid\n  left_on     TEXT                   -- NULL if still in the club\n);\n\n-- some rows\n-- 1 | Ava    | Brooks  | 10 | 2026-09-02 | 1 | NULL\n-- 2 | Mateo  | Chen    | 11 | 2025-09-10 | 1 | NULL\n-- 3 | Zoe    | Adams   | 9  | 2026-08-20 | 0 | NULL\n-- 4 | Liam   | Brooks  | 12 | 2026-08-15 | 1 | NULL\n-- 5 | Nia    | Davis   | 10 | 2026-09-30 | 1 | 2026-10-21\n\n-- what I have so far (shows everyone):\n-- SELECT * FROM members;\n\n-- Mr. Grant (club advisor) says the tournament list should look like\n-- the sign-in sheet, last names in alphabetical order.","rules":[{"type":"codeBlocks","count":1},{"type":"maxCodeLines","max":8},{"type":"maxProseWords","max":30}],"mistakes":[{"title":"Not giving the date","why":"The AI can't know your school year started Aug 15, so it guesses or skips the filter.","fix":"Add: \"Only joined_on >= '2026-08-15'.\"","checks":["r0"]},{"title":"Missing a rule","why":"The AI might only check dues or only check left_on.","fix":"Add: \"dues_paid = 1 AND left_on IS NULL.\"","checks":["r1"]},{"title":"SELECT * and no order","why":"The AI keeps SELECT * or sorts by first name.","fix":"Add: \"Only first_name, last_name; ORDER BY last_name, first_name.\"","checks":["r2"]},{"title":"A SQL lesson","why":"The AI explains every keyword.","fix":"Add: \"One query in one code block, one sentence at most.\"","checks":["codeBlocks","maxCodeLines","maxProseWords"]}],"promptHints":[{"label":"Gives the date","patterns":["2026-08-15","school year","joined"]},{"label":"Gives the other rules","patterns":["dues","left_on","is null"]},{"label":"Names the columns","patterns":["first_name","last_name","column"]},{"label":"Gives the sort","patterns":["order by","alphabetical","sorted"]},{"label":"Asks for one query","patterns":["one query","only the query","one code block"]}],"hint":"The AI can't know who's allowed to play. Tell it every rule, the columns you want and the order.","rubricLabels":["Keeps only members with joined_on >= '2026-08-15' (on or after, so Liam Brooks is included)","Keeps only dues_paid = 1 and left_on IS NULL (using IS NULL, not = NULL)","Selects exactly first_name and last_name, ordered by last_name and then first_name"]}