K
knowshowrosegrows
Can someone help me create a query that:
1. Searches Between [Starting Census Date] And [Ending Census Date] from
tblCensusEvent.CensusDate
2. Finds the tblDPASCap.Capacity that was EFFECTIVE (tblDPASCap.EFFECTIVE)
during the above period for each tblProgram_Details.DPAS_Code.
3. Sums the Capacity for all the tblProgram_Details.DPASCode that comprises
each tblProgram_Details.Program_ID record.
tblCensusEvent
[Program_ID] [Census_ID] [CensusDate]
111 A 3-3-2004
111 C 3-3-2005
222 B 3-3-2004
222 D 3-3-2005
tblDPASCap
[DPAS] [Capacity] [EFFECTIVE]
41663 16 1-1-2004
41663 12 1-1-2005
41663 10 1-1-2006
57891 46 1-1-2004
57891 120 1-1-2005
57891 80 1-1-2006
38806 15 1-1-2004
tblProgram_Details
[Program_ID] [DPAS_Code]
111 41663
111 57891
222 38806
So a Census Event that took place on 3-3-04 for Program_ID 111 would have a
total capacity of 62 (sum 16 and 46). If an event for Program_ID 111 took
place on 3-3-05 the capacity would come out to 132.
An Event on 3-3-04 or 3-3-05 for Program_ID 222 would have a capacity of 15.
The tricky part of the formula is choosing the tblDPASCap record that has an
EFFECTIVE that has a range that the CensusDate fall in line with.
1. Searches Between [Starting Census Date] And [Ending Census Date] from
tblCensusEvent.CensusDate
2. Finds the tblDPASCap.Capacity that was EFFECTIVE (tblDPASCap.EFFECTIVE)
during the above period for each tblProgram_Details.DPAS_Code.
3. Sums the Capacity for all the tblProgram_Details.DPASCode that comprises
each tblProgram_Details.Program_ID record.
tblCensusEvent
[Program_ID] [Census_ID] [CensusDate]
111 A 3-3-2004
111 C 3-3-2005
222 B 3-3-2004
222 D 3-3-2005
tblDPASCap
[DPAS] [Capacity] [EFFECTIVE]
41663 16 1-1-2004
41663 12 1-1-2005
41663 10 1-1-2006
57891 46 1-1-2004
57891 120 1-1-2005
57891 80 1-1-2006
38806 15 1-1-2004
tblProgram_Details
[Program_ID] [DPAS_Code]
111 41663
111 57891
222 38806
So a Census Event that took place on 3-3-04 for Program_ID 111 would have a
total capacity of 62 (sum 16 and 46). If an event for Program_ID 111 took
place on 3-3-05 the capacity would come out to 132.
An Event on 3-3-04 or 3-3-05 for Program_ID 222 would have a capacity of 15.
The tricky part of the formula is choosing the tblDPASCap record that has an
EFFECTIVE that has a range that the CensusDate fall in line with.