Kaup, Chester
Chester_Kaup at kindermorgan.com
Tue Dec 12 11:03:37 CST 2006
I have been working on the following moving average query and get results of 4 records for each date. One of the values in the average column appears to be the right one. I am probably missing something simple but need some help. SELECT DISTINCTROW dbo_Month_Rates.VM_Well, dbo_Month_Rates.VM_Date_1, dbo_Month_Rates.VM_oil, Avg(dbo_Month_Rates_1.VM_oil) AS AvgOfVM_oil FROM dbo_Month_Rates INNER JOIN dbo_Month_Rates AS dbo_Month_Rates_1 ON dbo_Month_Rates.VM_Well = dbo_Month_Rates_1.VM_Well GROUP BY dbo_Month_Rates.VM_Well, dbo_Month_Rates.VM_Date_1, dbo_Month_Rates.VM_oil, dbo_Month_Rates_1.VM_Date_1 HAVING (((dbo_Month_Rates.VM_Well)="53-1") AND ((dbo_Month_Rates_1.VM_Date_1) Between [dbo_Month_Rates].[VM_Date_1]-92 And [dbo_Month_Rates].[VM_Date_1])) ORDER BY dbo_Month_Rates.VM_Date_1; Chester Kaup Engineering Technician Kinder Morgan CO2 Company, LLP Office (432) 688-3797 FAX (432) 688-3799 No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.