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  

Simple Subtraction



 
 
Thread Tools Display Modes
  #1  
Old June 28th, 2004, 02:04 PM
George
external usenet poster
 
Posts: n/a
Default Simple Subtraction

I have two tables with the exact same format/structure. One is for the end of month 1, the other is for the end of month 2. Each table contains four fields, and the same number of records (model, color, price, amount). I want a query that will return the change in the amount field. How do I join the tables (join on 1, 2, 3, or all 4 fields?), and what is the SQL to generate the query result?

Thanks
  #2  
Old June 28th, 2004, 02:53 PM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default Simple Subtraction

George

You may want to consider revising your table structure. The "one table per
month" design you described may work in a spreadsheet, but causes you (and
Access) headaches.

Access is a relational database, and can handle the situation by simply
adding a field into a single table that hold a date for that row. Thus, all
the rows where Month = 1 in this new table (or =2, or ...) is a simple
query.


--
Good luck

Jeff Boyce
Access MVP

  #3  
Old June 28th, 2004, 03:44 PM
George
external usenet poster
 
Posts: n/a
Default Simple Subtraction

Thanks for the insight. However, I may have made this sound easier than it is. Each database I have consists of several tables, one of which is the amount table described below. In my current database I am importing (linking to) a table from a different database (file). Now that I have the two tables, I want to subtract them and find the net gain or loss for each "category". My current approach is to join the two tables on the three "categories" (model, color, price) and calculates the difference between the two amount fields. It seems slow (30 seconds for 1,000,000 records). I was hoping for a more efficient way to get the net results.

"Jeff Boyce" wrote:

George

You may want to consider revising your table structure. The "one table per
month" design you described may work in a spreadsheet, but causes you (and
Access) headaches.

Access is a relational database, and can handle the situation by simply
adding a field into a single table that hold a date for that row. Thus, all
the rows where Month = 1 in this new table (or =2, or ...) is a simple
query.


--
Good luck

Jeff Boyce
Access MVP


  #4  
Old June 30th, 2004, 01:20 AM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default Simple Subtraction

George

You can sometimes get better performance if the fields on which you select
and/or join are indexed in their respective table.

--
Good luck

Jeff Boyce
Access MVP

 




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
Simple burning of a simple slide show to CDs Scott Powerpoint 1 June 8th, 2004 04:26 PM
Simple or not so simple animation.....? ZR Powerpoint 1 May 19th, 2004 05:10 AM
Calculate SIMPLE interest?? Fred Smith Worksheet Functions 1 February 4th, 2004 05:25 AM


All times are GMT +1. The time now is 08:41 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.