A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Create a "running total" field in a query in Access so I can use .



 
 
Thread Tools Display Modes
  #1  
Old August 31st, 2004, 03:34 PM
rhingomills
external usenet poster
 
Posts: n/a
Default 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  
Old August 31st, 2004, 10:10 PM
Michel Walsh
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 09:23 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.