473,385 Members | 1,912 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,385 software developers and data experts.

How can I construct a query to track changes in account balances over time?

I have some data in a table structured like this:

Date Cust_ID CUSIP Amount
01/31/2005 060208 02507M303 27,061.84
02/28/2005 060208 02507M303 32,049.00

Is there a way to construct a query that will give me the difference by
customer and CUSIP by month?

The real app has over 200,000 records (12 months with 20,000+ entries per
month) and I want to be able to track changes each month by the two fields.
I know how to sum them, group them, append, delete, etc. I even can figure
out how to do this if they were in separate tables, but I'm thinking there
must be a way to do it with the data in one table.

Any ideas?

Thanks.

p.s. not that it matters, but CUSIP is a code to track stocks, bonds, and
mutual funds.

Nov 13 '05 #1
5 2300
If by 'difference' you mean the Amount column field values then;

In the query edit;
- Include your table
- Include the Cust_Id, CUSIP and Amount fields
- Create a column with heading MonthDate : Format([Date], "mmyyyy")

Click on the group by button and;
- Group by Cust_Id, CUSIP, MonthDate
- Sum Amount

You might want to sort on 1/more of the grouped-by fields.

Colleyville Alan wrote:
I have some data in a table structured like this:

Date Cust_ID CUSIP Amount
01/31/2005 060208 02507M303 27,061.84 02/28/2005 060208 02507M303 32,049.00
Is there a way to construct a query that will give me the difference by customer and CUSIP by month?

The real app has over 200,000 records (12 months with 20,000+ entries per month) and I want to be able to track changes each month by the two fields. I know how to sum them, group them, append, delete, etc. I even can figure out how to do this if they were in separate tables, but I'm thinking there must be a way to do it with the data in one table.

Any ideas?

Thanks.

p.s. not that it matters, but CUSIP is a code to track stocks, bonds, and mutual funds.


Nov 13 '05 #2
<cc*****@slingshot.co.nz> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
If by 'difference' you mean the Amount column field values then;

In the query edit;
- Include your table
- Include the Cust_Id, CUSIP and Amount fields
- Create a column with heading MonthDate : Format([Date], "mmyyyy")

Click on the group by button and;
- Group by Cust_Id, CUSIP, MonthDate
- Sum Amount

You might want to sort on 1/more of the grouped-by fields.

No, by "difference" I mean the change from one month to the next. In the
example I've shown
Date Cust_ID CUSIP Amount
01/31/2005 060208 02507M303 27,061.84
02/28/2005 060208 02507M303 32,049.00

The difference between Jan and Feb balances is an increase of 4,987.16
If I had the data in two separate tables, one with Jan info and the other
with Feb info,
I could link the tables by the Cust_ID and by CUSIP and calculate the
change. The output
would look like this:

CUSIP Cust_ID Date_1 Date_2 Amount_1
Amount_2 Diff
02507M303 060208 01/31/2005 02/28/2005 27,061.84
32,049.00 -4987.16

But how do I do that when both dates are in the same table? I've tried a
crosstab query, but all I managed
to do was to get the amounts by date side-by-side and not calc the
difference.

Cust_ID CUSIP Jan Feb Mar Apr
May Jun Jul Aug Sep Oct Nov Dec
000087 02507M303 27,061.84 32,049.00

I have a bunch of blank months off to the right, but no change between the
two. The query wizard does not help much.

Any ideas on how to solve this?

Thanks.
Alan

I have some data in a table structured like this:

Date Cust_ID CUSIP Amount
01/31/2005 060208 02507M303

27,061.84
02/28/2005 060208 02507M303

32,049.00

Is there a way to construct a query that will give me the difference

by
customer and CUSIP by month?

The real app has over 200,000 records (12 months with 20,000+ entries

per
month) and I want to be able to track changes each month by the two

fields.
I know how to sum them, group them, append, delete, etc. I even can

figure
out how to do this if they were in separate tables, but I'm thinking

there
must be a way to do it with the data in one table.

Any ideas?

Thanks.

p.s. not that it matters, but CUSIP is a code to track stocks, bonds,

and
mutual funds.

Nov 13 '05 #3
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in
news:37*************@individual.net:
<cc*****@slingshot.co.nz> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
If by 'difference' you mean the Amount column field values
then;

In the query edit;
- Include your table
- Include the Cust_Id, CUSIP and Amount fields
- Create a column with heading MonthDate : Format([Date],
"mmyyyy")

Click on the group by button and;
- Group by Cust_Id, CUSIP, MonthDate
- Sum Amount

You might want to sort on 1/more of the grouped-by fields.

No, by "difference" I mean the change from one month to the
next. In the example I've shown
Date Cust_ID CUSIP
Amount 01/31/2005 060208 02507M303
27,061.84 02/28/2005 060208 02507M303
32,049.00

The difference between Jan and Feb balances is an increase of
4,987.16
If I had the data in two separate tables, one with Jan info
and the other with Feb info,
I could link the tables by the Cust_ID and by CUSIP and
calculate the change. The output
would look like this:

CUSIP Cust_ID Date_1 Date_2
Amount_1 Amount_2 Diff
02507M303 060208 01/31/2005 02/28/2005
27,061.84 32,049.00 -4987.16

But how do I do that when both dates are in the same table?
I've tried a crosstab query, but all I managed
to do was to get the amounts by date side-by-side and not calc
the difference.


Instead of separate tables, you can use separate queries on the
same table and use those in a query. So first build a query that
returns the previous month's balance, and join it to a query of
the current month's balance. It means you have two queries in the
database instead of one, but it's rarely a problem. You can
actually put the subquery as a field definition and only have
one query definition in the database, but it's tricky and
requires a bit of experience with SQL.

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #4
"Bob Quintal" <rq******@sPAmpatico.ca> wrote in message
news:1108850576.fc04aaadf7959632f709135bbc11eac5@t eranews...

Instead of separate tables, you can use separate queries on the
same table and use those in a query. So first build a query that
returns the previous month's balance, and join it to a query of
the current month's balance. It means you have two queries in the
database instead of one, but it's rarely a problem. You can
actually put the subquery as a field definition and only have
one query definition in the database, but it's tricky and
requires a bit of experience with SQL.

I never knew you could put a saved query in a new query. I always thought
you could only add tables.
Thanks

Nov 13 '05 #5
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in
news:37*************@individual.net:
"Bob Quintal" <rq******@sPAmpatico.ca> wrote in message
news:1108850576.fc04aaadf7959632f709135bbc11eac5@t eranews...

Instead of separate tables, you can use separate queries on
the same table and use those in a query. So first build a
query that returns the previous month's balance, and join it
to a query of the current month's balance. It means you have
two queries in the database instead of one, but it's rarely a
problem. You can actually put the subquery as a field
definition and only have one query definition in the
database, but it's tricky and requires a bit of experience
with SQL.

I never knew you could put a saved query in a new query. I
always thought
you could only add tables.
Thanks

Why this escapes so many neophytes is beyond me. As soon as
someone opens the query builder, a dialog menu pops up, with the
tabs "tables", "queries", "both". It seems logical to me that
they are there to be used.

I have one report at work that contains nine layers of queries
back to the tables. It's slow, but it works.

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Igorati | last post by:
Hello all, I am still needing some help on this code, I have gone a bit further on it. Thank you for the help. I am trying to understand how to make the file searchable and how I am to make the...
22
by: Robert Brown | last post by:
suppose I have the following table: CREATE TABLE (int level, color varchar, length int, width int, height int) It has the following rows 1, "RED", 8, 10, 12 2, NULL, NULL, NULL, 20...
3
by: rong.guo | last post by:
Hello group! I am having a problem with simplying my query... I would like to get customers' balance info based on how many months since they opened their accounts. The tricky part here is...
7
by: Mark Carlyle via AccessMonster.com | last post by:
I have this update query that I am trying to run. I know the syntax is messed up but do not know how to correct it. Select 'UPDATE', Transactions,'Set = where = ' From "Get Daily Balances" ...
5
by: jmartineau | last post by:
Hello, Here is a brief summary: Table 1 = All Accounts - with fields such as Customer ID and Account # Table 2 = Deposit Balance Table - with fields such as Account #, Balance
2
by: audiophilechris | last post by:
Can anyway help me write this query? I've created a DB to help me manage delivery logistics for items I rent out. I have a table that i use to record delivery date, delivery time, pickup date,...
2
by: Stephenoja | last post by:
Hello Guys, I have a problem that has to do with Aging Accounts Receivable. I have three tables with customer account numbers, customer names, customer balances for the years 2003, 2004 and...
1
by: midnightoil | last post by:
First, thanks for having a look at this post. I am trying to create a query that shows decrementing account balances. It reads the following fields from my tbl/Activity table: Customer ID, Week...
15
by: Widge | last post by:
Hi, I wondered if you could help me with an issue I'm having. Currently I have a rebate calculation that is running off two tables: 1) A list of suppliers and the rebate %ages relevant to them...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.