Re: date problem - Mailing list pgsql-general

From Roman Neuhauser
Subject Re: date problem
Date
Msg-id 20050516083055.GA46490@isis.sigpipe.cz
Whole thread Raw
In response to date problem  (tony <tony@tgds.net>)
Responses Re: date problem
List pgsql-general
# tony@tgds.net / 2005-05-16 09:48:08 +0200:
> I am attempting to select records where one of the dates is the latest
> date before today
>
> select max(date) from expo where date < now()
>
> works for one record but other fields I need must be in aggregate or
> grouped. Is there a simple SQL request to get the most recent records
> from a set of joined tables?

    select *
    from expo
    where date = (select max(date)
                  from expo
                  where date < now()) as x;

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

pgsql-general by date:

Previous
From: tony
Date:
Subject: date problem
Next
From: Richard Huxton
Date:
Subject: Re: date problem