[AccessD] Moving Average Query

Kaup, Chester Chester_Kaup at kindermorgan.com
Tue Dec 12 15:13:12 CST 2006


I found the error in the query. Needs to read like this.

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

WHERE ((dbo_Month_Rates_1.VM_Date_1) Between
[dbo_Month_Rates].[VM_Date_1]-92 And [dbo_Month_Rates].[VM_Date_1])

GROUP BY dbo_Month_Rates.VM_Well, dbo_Month_Rates.VM_Date_1,
dbo_Month_Rates.VM_oil

HAVING (((dbo_Month_Rates.VM_Well)="53-1"))

ORDER BY dbo_Month_Rates.VM_Date_1;

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup, Chester
Sent: Tuesday, December 12, 2006 11:04 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Moving Average Query

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.

 

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list