{"id":"code-work-pm-sql-onboarding-funnel","audience":"product-managers","category":"coding","track":"coding","technique":"context","title":"Count an October onboarding funnel in New York time","free":false,"task":"Write one SQL query for October 2026 that returns one row with three columns, signed_up, created_project and invited_teammate, each the number of distinct users with that event (count each step on its own). Our reports run on New York time, but created_at is stored in UTC, so convert it (AT TIME ZONE) before filtering October. Leave out internal users (is_internal = true). One code block, at most 15 lines, then under 25 words outside the code.","materialLabel":"Schema and sample rows (attached to your prompt automatically)","material":"PRODUCT DATABASE - Tallyboard (Postgres)\n\nTable: events\n- id (bigint)\n- user_id (bigint)\n- event_name (text): 'signed_up', 'created_project', 'invited_teammate', 'viewed_pricing', ...\n- created_at (timestamp without time zone, stored in UTC)\n\nTable: users\n- id (bigint)\n- email (text)\n- is_internal (boolean)\n- plan (text)\n\nSample events:\nid | user_id | event_name | created_at\n901 | 77 | signed_up | 2026-10-01 02:12\n902 | 77 | created_project | 2026-10-03 09:20\n903 | 77 | created_project | 2026-10-04 14:02\n904 | 77 | created_project | 2026-10-09 11:45\n905 | 81 | signed_up | 2026-11-01 01:50\n906 | 12 | invited_teammate | 2026-10-12 16:30\n\nNotes:\n- The data team says events older than 2024 are in a cold-storage table.\n- viewed_pricing fires on every page load of the pricing page.\n- The plan column was added in March.","rules":[{"type":"codeBlocks","count":1},{"type":"maxCodeLines","max":15},{"type":"maxProseWords","max":25}],"mistakes":[{"title":"Not mentioning the time zone","why":"The AI filters on raw UTC times, so evening signups on the last day land in the wrong month.","fix":"Add: \"created_at is UTC; convert to America/New_York before filtering.\"","checks":["r0"]},{"title":"Forgetting the staff accounts","why":"The AI can't know internal users pad the numbers unless you say to drop them.","fix":"Add: \"Exclude users where is_internal is true.\"","checks":["r1"]},{"title":"Leaving the output shape open","why":"The AI returns one row per event name, or a long chain of CTEs, instead of the row you'll paste.","fix":"Add: \"One row, columns signed_up, created_project, invited_teammate, distinct users.\"","checks":["r2","maxCodeLines"]},{"title":"Getting a menu of options","why":"The AI likes to offer two or three versions of the query, so you're left to pick and test them yourself.","fix":"Add: \"Give one query only, in one code block, no alternatives.\"","checks":["codeBlocks","maxCodeLines"]},{"title":"Getting a tutorial","why":"By default the AI explains every part of the code at length, which you then have to scroll past.","fix":"Add: \"After the code, one line under 15 words. Nothing else.\"","checks":["maxProseWords"]}],"promptHints":[{"label":"Handles the time zone","patterns":["time zone","new york","utc","eastern"]},{"label":"Drops internal accounts","patterns":["is_internal","internal","staff"]},{"label":"Asks for distinct users","patterns":["distinct","unique users"]},{"label":"Shows the output columns","patterns":["one row","signed_up.{0,40}invited_teammate","columns?"]},{"label":"Asks for one answer only","patterns":["\\b(one|single|1)\\s+(query|code block|block|version)","only one","no (alternatives|options|other versions)"]}],"hint":"The AI doesn't know your reports run on New York time or that some users are staff. Tell it both, and describe the one row you want back.","rubricLabels":["Converts created_at from UTC to New York time before filtering (such as created_at AT TIME ZONE 'UTC' AT TIME ZONE 'America/New_York'), then keeps October 1 up to, but not including, November 1, 2026","Excludes internal users by joining users on events.user_id = users.id and filtering is_internal = false (or NOT is_internal)","Returns one row with columns named signed_up, created_project and invited_teammate, each counted with COUNT(DISTINCT user_id) (for example COUNT(DISTINCT CASE WHEN ...) or FILTER)"]}