[AccessD] Query not returning any records

Kaup, Chester Chester_Kaup at kindermorgan.com
Mon Sep 26 15:04:22 CDT 2011


Thanks! That works.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of David McAfee
Sent: Monday, September 26, 2011 2:53 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Query not returning any records

SELECT
    dbo_WellTests.Well_API_14,
    dbo_WellTests.Well_Name,
    Max(dbo_WellTests.TestDate) AS MaxOfTestDate
FROM dbo_WellTests
WHERE dbo_WellTests.Well_Name="109-2" AND dbo_WellTests.TestDate<#9/1/2011#
GROUP BY dbo_WellTests.Well_API_14, dbo_WellTests.Well_Name

On Mon, Sep 26, 2011 at 12:22 PM, Kaup, Chester <
Chester_Kaup at kindermorgan.com> wrote:

> Maybe I need some different syntax. I want the last record before 9/1/2011
> i.e. the record dated 8/28/2011.
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com [mailto:
> accessd-bounces at databaseadvisors.com] On Behalf Of Bobby Heid
> Sent: Monday, September 26, 2011 2:09 PM
> To: 'Access Developers discussion and problem solving'
> Subject: Re: [AccessD] Query not returning any records
>
> Chester,
>
> Well, right off the bat, you have Max(dbo_WellTests.TestDate) <#9/1/2011#
> and the maximum date in your list is 9/1/2011.  So max(9/1/2011) is not
> less
> than 9/1/2011.  So you get no records.
>
> Bobby
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup, Chester
> Sent: Monday, September 26, 2011 3:01 PM
> To: Access Developers discussion and problem solving
> Subject: [AccessD] Query not returning any records
>
> When I run the following query I get the results listed below
>
> SELECT dbo_WellTests.Well_API_14, dbo_WellTests.Well_Name,
> dbo_WellTests.TestDate FROM dbo_WellTests GROUP BY
> dbo_WellTests.Well_API_14, dbo_WellTests.Well_Name, dbo_WellTests.TestDate
> HAVING (((dbo_WellTests.Well_Name)="109-2"));
>
> Well_API_14    Well_Name TestDate
> 42415034120000 109-2     6/7/2011
> 42415034120000 109-2     6/8/2011
> 42415034120000 109-2     8/7/2011
> 42415034120000 109-2     8/28/2011
> 42415034120000 109-2     9/1/2011
> 42415034120000 109-2     9/5/2011
>
> However when I run the following query I get no records returned. The table
> dbo_Welltests is an SQL Server table if that matters.
>
> SELECT dbo_WellTests.Well_API_14, dbo_WellTests.Well_Name,
> Max(dbo_WellTests.TestDate) AS MaxOfTestDate FROM dbo_WellTests GROUP BY
> dbo_WellTests.Well_API_14, dbo_WellTests.Well_Name HAVING
> (((dbo_WellTests.Well_Name)="109-2") AND
> ((Max(dbo_WellTests.TestDate))<#9/1/2011#));
>
> Thanks.
>
>
> 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
>
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
-- 
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