Re: Newbie question re SQL

From: missive(at)frontiernet(dot)net (Lee Harr)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Newbie question re SQL
Date: 2002-03-03 20:07:42
Message-ID: slrna850fo.4a.missive@whave.frontiernet.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>> Quan Price Cost
>>>==== ===== ====
>>> 300 125 37,500
>>> 500 135 67,500
>>> (100) 110 (13,125) <-- how do you get this number?
>
> When I sell a security, to calculate the cost of the remaining
> identical securities, I must subtract from my total cost before the
> sale the number of units sold * their cost per unit (not their fair
> market value at the time of the sale).
>

I was reading recently that it can be helpful to access the
database _only_ through functions. Basically, create an API
for accessing your data. So you might create functions:

buy(id, quan, price)
sell(id, quan, price)

which would deal with your accounting situation.

Maybe you could keep a table with the to-date cost which
gets updated each time you buy() or sell()

You might also look at sourceforge.net as I remember reading
about an accounting system written for sql databases.
(Someone may already have scratched this itch :)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message montfort 2002-03-03 20:08:39 error
Previous Message Regis 2002-03-03 18:39:13 Explain SQL feature