I have data on air pollution coming from sources across the country,
and control options for reducing pollution from each source. The
example below shows data for:
- 2 sources (plant_ID "001" and "008")
- total tons of pollution emitted from each source (20 and 25 tons,
respectively)
- an ID code for the each control device that could be applied to
reduce the emissions
- the control efficiency for each control device (percent that it
would reduce the emissions)
- the tons that each control device would reduce the emissions
I need to create an Access query that will calculate the incremental
tons reduced ("inc_red"), i.e., the difference between the tons reduced
by the device listed in the current record minus the tons reduced by
the device in the previous record, if the previous record is for the
same plant. Eg., the 1st control device is listed in record # 2 and it
would reduce emissions a total of 10 tons. The 2nd control device is
listed in record # 3 and it would reduce emissions a total of 10 tons.
The incremental difference is calculated by subtracting the reduction
for record # 2 from the reduction for record # 3, which equals zero
(because they are both 10). I have greatly simplified the problem, but
this gets at the essence of my problem. I have a database of over
100,000 records for which I need to do similar calculations, and the
database is updated regularly.
ID plant_ID total_tons_emitted control_ID CE tons_reduced
inc_red
1 001 20 no control
2 001 20 N01 0.5 10 10
3 001 20 N08 0.5 10 0
4 001 20 N03 0.8 16 6
5 008 25 no control
6 008 25 N04 0.4 10 10
7 008 25 N07 0.6 15 5