473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

SQL Stock Query - Summing fields to use in Multiplication

Hello all!

I have a logic problem that I have been working on for quite some time now and can't seem to fix. Hopefully someone can shed some light on the subject.
I am starting to work on an access database that will hold stock data. The database needs to be able to do the following:
Compute the correct amount of stock share dividends that each individual receives, at runtime.

Let me explain further. There are 3 tables:
tblFund
=====
FundID
FundName
FundPrice

tblReg
====
RegID
RegName

tblInvestment
=========
InvestmentID
RegID - fk
FundID - fk
InvestDate
UnitPurchase (how many shares they bought/sold)

These three tables make up the buying / selling side of things.
To handle the dividends I have the following:

tblDividend
========
DivID
FundID - fk
DivAmt
DivDate

The DivAmt is based on 1 unit (and unfortunately this is the way it must be done, i.e. the dividends for each person cannot be entered separately). So, if a stock distributes .5 shares per 1 unit. Then a registration that ownes 4 units would receive 2 units, making the grand total shares owned 6.

The problem I am having is the SQL in the query to retrieve this information.
I'm needing a query that would render similar to the following:
Expand|Select|Wrap|Line Numbers
  1. FundID RegID   Date        OrginalPurchase  TotalDivAmt     TotalUnitsOwned
  2. 1             1     11/14/05          10                   20                       30
  3. 1             1     12/15/05          10                   60                       90
  4. 1             1     1/14/06          10                     45                      135
  5.  
Edit: I can't get the info to display properly but, it should read 20, 60, 45 for totaldivamt and 30, 90, 135 for Total Units Owned.

The 1 Unit Dividends for the above table in order were 2, 2, and .5

As you can see what happens is the share dividends the person receives increases their units owned. This new total of units owned then needs to be used to calculate the next dividend amount. And so on and so forth.

Using a previous rows sum is what seems to really be giving me the trouble. I'm not sure if this is possible, or what but that is essentially (at least from what I can tell) I am needing to do.

Any suggestions on how to do this, or another way of approaching the problem would be great!

Thank you all in advance.
Jan 30 '08 #1
2 3155
MMcCarthy
14,534 Expert Mod 8TB
Will there be more than one dividend per fund?
Will there be only one fund per dividend?
Can an investment refer to more than one fund?
Feb 5 '08 #2
Will there be more than one dividend per fund?
Will there be only one fund per dividend?
Can an investment refer to more than one fund?
Yes, typically a dividend will occur once a month.
The dividend would refer specifically to a particular fund.
The investment has the particular RegID (person purchasing), FundID (particular fund they are purchasing), UnitsPurchased (how many they are buying), and Date (Date transaction took place).

So, to answer your third question, yes...? A person (i.e. RegID) can invest in multiple funds (i.e. FundID) and can invest in the same fund multiple times (i.e. purchase more shares or sell off shares).

Hopefully that helps :)
Feb 5 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Targa | last post by:
<input NAME="TAXRATE" onBlur="this.form.TAX.value = (this.form.TAXRATE.value - 0) * (this.form.ITEM1TOTAL.value - 0) + (this.form.ITEM2TOTAL.value - 0) " Size="4"> In my TAX field I get...
0
by: flamingo | last post by:
I have a query that works just fine, but because I need to use it in Business Objects and I have to use a prompt for the date, I need the initial query for the count as a correlated subquery in the...
0
by: flamingo | last post by:
I have a query that works just fine, but because I need to use it in Business Objects and I have to use a prompt for the date, I need the initial query for the count as a correlated subquery in the...
1
by: nickey000_0000 | last post by:
I have a database that contains a circuit ID in two different fields. One is the old number and the other is a new number. I want one query that will look in both fields for the query, Like I...
4
by: dancole42 | last post by:
So I have an invoicing database based on two main forms: Orders and OrderLines. Orders has fields like: OrderID BillingMethod OrderDate CreditCard CCExp OrdSubTotal ShippingCharge
2
by: BurtonBach | last post by:
I would like to write a query that would return all records within a single table "Imported Transactions" where two fields are duplicated. For example I am looking at the 'Date' & 'TransNum' fields....
1
by: hinze | last post by:
Hi, this is my first ever post, so go easy on me... I want to update some fields from table 'cases' to some fields in another table 'casesandcontrols'. For example I want to add the PSA data from...
45
by: dizzydangler | last post by:
Hi, I'm new to access (2007, running on XP), but I've gotten some great help from this site on my project so far. However, the more I know, the more complex the problems seem to become.... I'm...
12
doma23
by: doma23 | last post by:
Hi, I have 5 fields on a form. Field1, Field2, Field3, Field4, SumField SumField is disabled as it is calculated field based on other four fields. SumField = Field1 + Field2 + Field3 + Field4 ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.