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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |