Re: Selecting the most recent date

Поиск
Список
Период
Сортировка
От Jay O'Connor
Тема Re: Selecting the most recent date
Дата
Msg-id 20030428115929.C1222@altaica
обсуждение исходный текст
Ответ на Selecting the most recent date  (Mark Tessier <m_tessier@sympatico.ca>)
Ответы Re: Selecting the most recent date  (Dennis Gearon <gearond@cvc.net>)
Список pgsql-general
On 2003.04.28 10:26 Mark Tessier wrote:
> Hi,
>
> My question is hopefully a simple one:  If I have several rows, each
> containing a date field, and I want to select the row that has the date
> closest to today's date, what would be the syntax for carrying that out.


Unless I misunderstand, it should be just a matter of an ORDER BY clause in
reverse order with a LIMIT BY clause to limit yuorself to the highest
result

    SELECT * from myyable ORDER BY datefield DESC LIMIT 1;

DESC  means to using a descending sorta order (versus "ASC")
LIMIT 1 means how many rows you want returned

Take care,
Jay


В списке pgsql-general по дате отправления:

Предыдущее
От: David Link
Дата:
Сообщение: Re: pq_recvbuf: unexpected EOF
Следующее
От: "Robert Fitzpatrick"
Дата:
Сообщение: Re: Setting a field to default if blank value