Kaup, Chester
Chester_Kaup at kindermorgan.com
Wed Jan 2 13:30:39 CST 2008
I don't think this will work because I only need to count the number of records between the last record and the first record (date descending) where the measurement is greater than 100. There may records further down in the table that are also above 100 but there are records below 100 between these and the first group. For example 12/31/2007 145 12/30/2007 175 12/29/2007 207 12/28/2007 123 12/27/2007 114 12/26/2007 90 12/25/2007 45 12/24/2007 73 12/23/2007 304 The correct answer in this case would be 5 -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hale, Jim Sent: Wednesday, January 02, 2008 1:19 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] I need a better way to do this - looping Couldn't you use a groupby query- something like SELECT Count(tblWellData.[fldMeasure date]) AS [CountOffldMeasure date] FROM tblWellData WHERE (((tblWellData.fldWellNo)=1) AND ((tblWellData.fldMeasure)<100)); For well 1 this gives you the number of records where the measurement is <100 HTH Jim Hale -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup, Chester Sent: Wednesday, January 02, 2008 12:35 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] I need a better way to do this - looping Let me try to explain what I am trying to calculate. Myds.Fields(4) is a pressure variance measurement on an oilfield injection well. It should always be below 100. The goal is to count the number of records (date descending) from the most recent to the first one where Myds1.Fields(4) is less than 100 for each well. The number of records per well varies. If all the records for a well have Myds.fields(4) with a value above 100 the correct answer is the number of records for the well. If record 11 descending from the most recent is less than 100 then the correct answer would be 10. Hope this makes sense. *********************************************************************** The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error please contact the sender and delete the material from any computer. As a recipient of this email, you are responsible for screening its contents and the contents of any attachments for the presence of viruses. No liability is accepted for any damages caused by any virus transmitted by this email. -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com