If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Create a "running total" field in a query in Access so I can use .
I am trying to create a running total in an Access query. An example would
be to have a table that I entered Date, Time, Buy or Sell, Price, and Shares for stocks. I would then want to create a query that would take this informationa and keep a running total of the value of the stock, and on the dates with "Sell" in the transaction field, the query would determine the historic price of all shares bought and sold before that date, and calculate the cost of the stock sold. |
#2
|
|||
|
|||
Hi,
SELECT a.pk, LAST(a.f1), LAST(a.f2), SUM(b.buy). SUM(b.sell) FROM myTable As a INNER JOIN myTable As b ON a.dateTime = b.dateTime GROUP BY a.pk where pk is the primary key, f1, f2 , .... fields you wish to get too. SUM(b.buy) would produce the SUM of every thing you buy; the exact expression can be SUM( b.qty * b.unitPriceBuy) , or even SUM(b.sell - b.bought), or something like that, I can tell at this moment, for lack of details. Hoping it may help, Vanderghast, Access MVP "rhingomills" wrote in message ... I am trying to create a running total in an Access query. An example would be to have a table that I entered Date, Time, Buy or Sell, Price, and Shares for stocks. I would then want to create a query that would take this informationa and keep a running total of the value of the stock, and on the dates with "Sell" in the transaction field, the query would determine the historic price of all shares bought and sold before that date, and calculate the cost of the stock sold. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Images in a database | Franz | General Discussion | 10 | October 7th, 2004 09:35 AM |
Memo Field Truncated in Access 97 query | bdehning | General Discussion | 2 | August 19th, 2004 04:11 PM |
Access vs. Excel query w/blank field | dutty | Running & Setting Up Queries | 1 | July 28th, 2004 01:10 PM |
Newbie? Do I use Report or Query | John Egan | New Users | 11 | June 28th, 2004 08:31 PM |
May you help me? output data MS Access query to excel and create chart. | slim004 | Charts and Charting | 1 | May 14th, 2004 11:34 AM |