Can somebody help me with update query?
I have two tables: T and S. Both tables have fields F1,F2,F3,F4. These fields identify common records on the tables. Table S has [Calendar Year] and [Calendar Month]fields. Also, for each (F1,F2,F3,F4) record, table S has some numeric parameter in field F5. This parameter is available for 12 Calendar Months within Calendar Year. As such, table S can have many (F1,F2,F3,F4) records.
Table S:
F1,F2,F3,F4, CY,CM,F5
______________________
A,B,C,D,2009,1,0.12345
A,B,C,D,2009,2,0.27138
.....
A,B,C,D,2009,11,0.7438
A,B,C,D,2009,12,0.3456
....
....
A,B,C,D,2010,1,0.62315
A,B,C,D,2010,2,0.12905
.....
A,B,C,D,2010,11,0.3561
A,B,C,D,2010,12,0.7343
Also, Table T has five quater-end fields, for example:
Table T
F1,F2,F3,F4, QD1,QD2,QD3,QD4,QD5
______________________
A,B,C,D,9/30/2009,12/31/2009,3/31/2010,6/30/2010,9/30/2010
I need:
1. For each record on Table T, find corresponding records on Table S (based on first four common fields).
2. Extract year from T.QD1 (2009 in the example).
3. For this year, I need to calculate SUM(S.F5) for calendar months 7,8,9 and calendar year = 2009 on Table S, and save it in, say, field, Calc1 on Table 5
4. Repeat it for all QD# fields. For example, for QD2, I need to calculate SUM(S.F5) for calendar months 10,11,12 and calendar year = 2009 on Table S, and save it in field Calc2 on Table 5.
I know, it sounds like to much to ask, but I will greatly appretiate any help!
Thank you!
vladk
I have two tables: T and S. Both tables have fields F1,F2,F3,F4. These fields identify common records on the tables. Table S has [Calendar Year] and [Calendar Month]fields. Also, for each (F1,F2,F3,F4) record, table S has some numeric parameter in field F5. This parameter is available for 12 Calendar Months within Calendar Year. As such, table S can have many (F1,F2,F3,F4) records.
Table S:
F1,F2,F3,F4, CY,CM,F5
______________________
A,B,C,D,2009,1,0.12345
A,B,C,D,2009,2,0.27138
.....
A,B,C,D,2009,11,0.7438
A,B,C,D,2009,12,0.3456
....
....
A,B,C,D,2010,1,0.62315
A,B,C,D,2010,2,0.12905
.....
A,B,C,D,2010,11,0.3561
A,B,C,D,2010,12,0.7343
Also, Table T has five quater-end fields, for example:
Table T
F1,F2,F3,F4, QD1,QD2,QD3,QD4,QD5
______________________
A,B,C,D,9/30/2009,12/31/2009,3/31/2010,6/30/2010,9/30/2010
I need:
1. For each record on Table T, find corresponding records on Table S (based on first four common fields).
2. Extract year from T.QD1 (2009 in the example).
3. For this year, I need to calculate SUM(S.F5) for calendar months 7,8,9 and calendar year = 2009 on Table S, and save it in, say, field, Calc1 on Table 5
4. Repeat it for all QD# fields. For example, for QD2, I need to calculate SUM(S.F5) for calendar months 10,11,12 and calendar year = 2009 on Table S, and save it in field Calc2 on Table 5.
I know, it sounds like to much to ask, but I will greatly appretiate any help!
Thank you!
vladk