| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Accounting ERD
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.comReceived on Sun Apr 27 2003 - 16:32:06 CDT
![]() |
![]() |