Re: date problem

From: tony <tony(at)tgds(dot)net>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: postgres list <pgsql-general(at)postgresql(dot)org>
Subject: Re: date problem
Date: 2005-05-16 08:51:37
Message-ID: 1116233497.8944.4.camel@hush
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Le lundi 16 mai 2005 à 09:44 +0100, Richard Huxton a écrit :

> > 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());
>
> In fact, you might want to rewrite the subselect. Oh, and "date" is
> likely to cause trouble as a column-name.
>
> SELECT * FROM expo
> WHERE my_date = (
> SELECT my_date FROM expo
> WHERE my_date < now()
> ORDER BY my_date DESC LIMIT 1
> )

Thanks! I wasn't really using date but for clarity had put that instead
of my French column name...

Tony

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stefan Hans 2005-05-16 09:51:38 UTF-8 and LC_CTYPE locale
Previous Message tony 2005-05-16 08:48:20 Re: date problem