faye
02-28-2006, 07:46 PM
Hi all, i am having a big headache figuring out this problem.
I have a table like this:
Table Name:Built
Part No.........................Date...............................Sum Of Built
ver10001....................2/1/2006...............................10000
ver10001....................3/1/2006...............................15000
ver10001....................4/1/2006...............................20000
ver10001....................5/1/2006...............................25000
ver10001....................6/1/2006...............................30000
And another table like this:
Table Name: Demand
Part No..........................Date................................Sum of Demand
ver10001.......................1/1/2006.................................2000
ver10001.......................2/1/2006.................................4000
ver10001.......................3/1/2006.................................6000
ver10001.......................4/1/2006.................................8000
ver10001.......................5/1/2006................................10000
ver10001.......................6/1/2006................................12000
Here's the question:
How can i use a sql query to subtract the [sum of Demand] from the [Sum of Built] Where the Date for the Table [Demand] is one month earlier than the Date for the Table [Built].
The resulted output should look like this:
Part No......................Date...........................Calculated Value
ver10001.................2/1/2006...............................8000
ver10001.................3/1/2006..............................11000
ver10001.................4/1/2006..............................14000
ver10001.................5/1/2006..............................17000
ver10001.................6/1/2006..............................20000
Please help!
Thank you
I have a table like this:
Table Name:Built
Part No.........................Date...............................Sum Of Built
ver10001....................2/1/2006...............................10000
ver10001....................3/1/2006...............................15000
ver10001....................4/1/2006...............................20000
ver10001....................5/1/2006...............................25000
ver10001....................6/1/2006...............................30000
And another table like this:
Table Name: Demand
Part No..........................Date................................Sum of Demand
ver10001.......................1/1/2006.................................2000
ver10001.......................2/1/2006.................................4000
ver10001.......................3/1/2006.................................6000
ver10001.......................4/1/2006.................................8000
ver10001.......................5/1/2006................................10000
ver10001.......................6/1/2006................................12000
Here's the question:
How can i use a sql query to subtract the [sum of Demand] from the [Sum of Built] Where the Date for the Table [Demand] is one month earlier than the Date for the Table [Built].
The resulted output should look like this:
Part No......................Date...........................Calculated Value
ver10001.................2/1/2006...............................8000
ver10001.................3/1/2006..............................11000
ver10001.................4/1/2006..............................14000
ver10001.................5/1/2006..............................17000
ver10001.................6/1/2006..............................20000
Please help!
Thank you