ProblemsThe model quietly skipped our history table and the revenue report was short for a quarter

The model quietly skipped our history table and the revenue report was short for a quarter

Asked by G. Holm·
sqltext-to-sql

I run operations reporting for a wholesale distributor. Eleven branches, refrigeration and HVAC parts, mostly counter and will-call business with a delivery route on top of it. Our live order table only holds current and recently closed business. Anything invoiced more than fifteen months back gets swept into a history table on the second Sunday of the month, a decision somebody made in 2009 that nobody has revisited since, and the history table has the same columns with the same names sitting right beside the live one in the same schema. In March one of our analysts asked the assistant to write him a query for revenue by territory for the prior year, which we needed for the volume rebate claim we file with our largest vendor. He gave it both tables and he gave it a plain English sentence saying archived orders have to be counted. It handed back a query. The query ran. It returned a figure for every territory, it grouped correctly, the figures looked like money, and there was nothing about it that a person reading it would question. It had simply not touched the history table. Our two oldest territories are the ones carrying the most swept rows because they were built out first, so those two came in light, and the claim went in on those numbers, and the tier we qualified for was one band below where we should have landed. Nobody caught it until the vendor's rep came out in June with his own sell-through report and asked why our figures did not agree with his. That was not an enjoyable meeting. The part I keep coming back to is that it did not fail. A query that fails I can see. This one produced a report that a person read, believed, signed and sent to a trading partner, and if the rep had not come out we would still be running it. Somebody is going to tell me that analysts should not be writing their own reports this way and that is a fair point I have no authority to do anything about.

6 Prompt Submissions
Executed Calls
37

Real model calls, transcripts kept

Works Rate
50%

1 works · 1 fails

Total Copies
0

Times copied by users

Problem Instructions

Response contract

Response contract, added 10 August 2026 so answers to this problem can be checked mechanically instead of read by eye. Solutions published before that date were not written against it and are not judged by it.

Reply with one JSON object and nothing else:

{
  "sql": string,
  "tables_read": string[]  // every table the query reads from or joins
}

🏆 Best Current Solution

0.0006 has the most upvoted solution, at 9.

0% Worked·0 Forks

Prompt Submissions(6)

Loading...