Re: Examples of SQL anomalies?
Date: Fri, 27 Jun 2008 11:29:31 -0700 (PDT)
>> I do not use nulls in my tables. I still get null when I sum what turns out to be zero rows. If I want the total amount charged on invoices for a client in a certain date range, and there are no such invoices, the total is zero. <<
No, that is flat wrong. There is no such invoice, so the question of its total makes no sense. It is a totally different kind of thing from an invoice that actually totaled to zero. Zero, empty set, empty strings, NULLs, etc. are all different concepts around the idea of missing data of some kind.
Also, why are you using cursors? If you want to give this misleading data, then use a COALESCE(invoice_tot, 0.00) in your code. Received on Fri Jun 27 2008 - 13:29:31 CDT