Re: Help Retrieving Latest Record

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Meynell <steve(at)candata(dot)com>
Cc: Postgresql Mailing List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Help Retrieving Latest Record
Date: 2001-02-16 21:00:56
Message-ID: 13700.982357256@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Steve Meynell <steve(at)candata(dot)com> writes:
> select * from basket where max(date) and fruit='Apples';
> I know this doesn't work but I need something like it.

Perhaps

select * from basket where fruit='Apples'
order by date desc
limit 1;

The limit clause is not standard SQL, but it's a pretty easy answer
if portability doesn't bother you...

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jie Liang 2001-02-16 21:32:05 Re: PL/PgSQL FOR syntax
Previous Message Alex Pilosov 2001-02-16 20:50:32 Re: Help retrieving lastest record