Help Retrieving Latest Record

From: Steve Meynell <steve(at)candata(dot)com>
To: Postgresql Mailing List <pgsql-sql(at)postgresql(dot)org>
Subject: Help Retrieving Latest Record
Date: 2001-02-16 14:41:09
Message-ID: 3A8D3C04.3D81B5BA@candata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi, I am not sure if this went through the first time so here it is
again.

Ok what I am trying to do is select out of the database the latest
record meeting a certain criteria.

Example:

Number | Fruit | Date
15 Apples July 20, 1999
20 Oranges June 7, 2000
13 Pears Jan 31, 2000
17 Apples April 10, 1999
Now what I need to do is select the oranges out because the date is the
latest one, something like:

select * from basket where max(date);
This would yield me:
20 Oranges June 7, 2000

I know this doesn't work but I need something like it.
or something like

select * from basket where max(date) and fruit='Apples';
This would yield me:
15 Apples July 20, 1999

Thank you in advance,

--
Steve Meynell
Candata Systems

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Justin Long 2001-02-16 16:16:41 Suggestions on finetuning this search?
Previous Message Bruce Momjian 2001-02-16 14:40:01 Re: [SQL] C/C++ interface