Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select data from MAX date -90 1

Status
Not open for further replies.

gwoman

Programmer
Nov 16, 2004
199
US
I'm trying to select production volume for a well for the most recent 3 months it has produced from the last day it produced. Below is my query ... I am only getting one record and it is 90 days from the MAX date none of the data in between is coming back ... any help would be much appreciated ... thanks so much!!!

SELECT Qry_WGR_Zach.well_id, Qry_WGR_Zach.Well, Qry_WGR_Zach.api_no, Qry_WGR_Zach.P_DATE, Qry_WGR_Zach.[Gas(MCF)], Qry_WGR_Zach.[Water(BBL)], ([Water(BBL)]/([Gas(MCF)]/1000)) AS [WGR(BBL/MMCF)], [Gas(MCF)]/31 AS [Gas(MCFD)], [Water(BBL)]/31 AS [Water(BWPD)], Qry_WGR_Max_Date_Zach.MaxOfP_DATE1
FROM Qry_WGR_Max_Date_Zach INNER JOIN Qry_WGR_Zach ON (Qry_WGR_Max_Date_Zach.Well = Qry_WGR_Zach.Well) AND (Qry_WGR_Max_Date_Zach.MaxOfP_DATE1 = Qry_WGR_Zach.P_DATE)
GROUP BY Qry_WGR_Zach.EU, Qry_WGR_Zach.PROPNUM, Qry_WGR_Zach.well_id, Qry_WGR_Zach.Well, Qry_WGR_Zach.api_no, Qry_WGR_Zach.P_DATE, Qry_WGR_Zach.[Gas(MCF)], Qry_WGR_Zach.[Water(BBL)], Qry_WGR_Max_Date_Zach.MaxOfP_DATE1
HAVING (((Qry_WGR_Zach.Well)="AP 21-23-696") AND ((Qry_WGR_Max_Date_Zach.MaxOfP_DATE1)=-90));
 
I dont realy understand your query but i dont think you need a group by

try
Code:
SELECT Qry_WGR_Zach.well_id, Qry_WGR_Zach.Well, Qry_WGR_Zach.api_no, Qry_WGR_Zach.P_DATE, Qry_WGR_Zach.[Gas(MCF)], Qry_WGR_Zach.[Water(BBL)], ([Water(BBL)]/([Gas(MCF)]/1000)) AS [WGR(BBL/MMCF)], [Gas(MCF)]/31 AS [Gas(MCFD)], [Water(BBL)]/31 AS [Water(BWPD)], Qry_WGR_Max_Date_Zach.MaxOfP_DATE1
FROM Qry_WGR_Zach
inner join Qry_WGR_Max_Date_Zach 
on Qry_WGR_Max_Date_Zach.Well = Qry_WGR_Zach.Well
where Qry_WGR_Max_Date_Zach.MaxOfP_DATE1 -90 <=Qry_WGR_Zach.P_DATE
 
Sorry missed well #

where Qry_WGR_Zach.Well="AP 21-23-696" and Qry_WGR_Max_Date_Zach.MaxOfP_DATE1 -90 <=Qry_WGR_Zach.P_DATE
 
HA ....
Not sure what I was thinking ...
Thanks PWise you ROCK!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top