Re: Accounting ERD

From: andrewst <member14183_at_dbforums.com>
Date: Sun, 27 Apr 2003 21:32:06 +0000
Message-ID: <2813354.1051479126_at_dbforums.com>


Originally posted by Kenneth Downs One column of numbers is simpler. Consider the most basic check of all,
> which is to see if it balances. You can do:
>
> SELECT SUM(trxamt) from Ledger
>
> Or you can do:
>
> SELECT SUM(debits) - SUM(credits) FROM Ledger
>
> While there is little difference between those two expressions,
> every small
> complication introduced at the beginning will multiply throughout the
> entire system. Better to squeeze for every measure of
> simplicity in the
> beginning and have a more manageable system when it gets larger.
>
>
Agreed. And it prompts me to share with you the egregious design I have to work with, which has 2 columns: amount and type, where type is effectively 'CREDIT' or 'DEBIT' and amount is always +ve. So to get the total you have to do something like:

SUM( CASE WHEN type='CREDIT' THEN amount ELSE -amount END ) FROM Ledger;

Horrible!

--
Posted via http://dbforums.com
Received on Sun Apr 27 2003 - 23:32:06 CEST

Original text of this message