simon551
IS-IT--Management
- May 4, 2005
- 249
Hi All,
I've run into a snag in designing my database (or at least my query). I'm trying to track stocks.
I have tables:
tblSecurities
SecID,Tckr, Description
tblInventory
LotID, SecID, PurchDate, NumShares
tblSales
SaleID, LotID, SaleDate, NumSold
Then I query for BalShares by NumShares-NumSold. I run into a problem if I sell the same lot twice. For example I may buy 1000 and Sell 500 twice.
When I run the query for BalShares I then have 1000 (1000-500 x2). Because the LotID is duplicated in the sale. I'm sure someone has run into this before, but I tried searching for keyword inventory and I'm not seeing an answer.
I've run into a snag in designing my database (or at least my query). I'm trying to track stocks.
I have tables:
tblSecurities
SecID,Tckr, Description
tblInventory
LotID, SecID, PurchDate, NumShares
tblSales
SaleID, LotID, SaleDate, NumSold
Then I query for BalShares by NumShares-NumSold. I run into a problem if I sell the same lot twice. For example I may buy 1000 and Sell 500 twice.
When I run the query for BalShares I then have 1000 (1000-500 x2). Because the LotID is duplicated in the sale. I'm sure someone has run into this before, but I tried searching for keyword inventory and I'm not seeing an answer.