DWIM: Do What I Mean
Way back in '86 I moved into IT working with what had recently been renamed from Marathon to Informix (much better name than Snickers!).
The system I started on was the older, non-SQL version. The application environment had a two classes of products. One class had serial numbers and individual rows in a table (or records in a file as the older Informix terminology had it). Assuming the warehouse hadn't misplaced any, stock levels could be assessed on demand by counting* the rows with the status code showing the individual items as being in the warehouse. The other class didn't and stock levels were assessed by dead reckoning between stock-takes. The code for determining stock level was a bit of C that looked at the product type and then did the appropriate bit of calculation. There were some complications around bill-of-materials issues in that some products consisted of assemblies of other products.
Eventually the older Informix version was to be replaced by SQL. A colleague wrote some YACC & Lex stuff** to do the grunt work of replacing much of the old-style C with the appropriate SQL versions. It left a good deal of manual tidying up to do and more complex bits, of which there were few but included the stock level calculation, had to be done by hand. I did the stock level by a somewhat convoluted bit of SQL involving NULL and the consequent 3-way logic. This ran successfully for years and survived migration to Informix on VAX, the reason for the SQL conversion, and a hasty retreat back to Unix, now on HP and Informix 2 to 4 and conversion of most if not all from C to Informix 4GL.
A little while after I'd moved on into freelance I had a gig with Informix which involved a bit of hand-holding with the old firm when they migrated to a bigger box and Informix 6 or 7. The actual cut-over date was after I'd finished the gig but I dropped in to make sure it was all working properly. I was told that in the end they'd discovered that in the entire suite there was one problem . I looked at it and recognised it at the SQL stock level calculation I'd written 10 years earlier. I looked again and realised there was an error in the 3-way logic, easily corrected. But for a decade this had run doing what I meant, not what I'd said. The really odd thing was that the bloke who'd taken my old job when I got eased out was convinced that the SQL was correct and there was a bug in the SQL engine. If there was it must have been that they'd dropped the telepathy function that worked out what I wanted it to do.
* At this remove I can't remember whether the C library used to access the database had the equivalent of the SQL COUNT or whether it had to be hand coded.
** I'd kept a copy of that. As the old ALL-2 library Informix wasn't going to be useful fro Y2K I hoped there'd be a market for last minute conversions. There wasn't.