Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f1GJTtx47888 for ; Fri, 16 Feb 2001 14:29:55 -0500 (EST) (envelope-from pgsql-sql-owner@postgresql.org) Received: from grunt.candata.com (gateway.candata.com [204.225.91.106]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f1GEc6x37139 for ; Fri, 16 Feb 2001 09:38:06 -0500 (EST) (envelope-from steve@candata.com) Received: from candata.com (steve@grunt.candata.com [192.168.1.15]) by grunt.candata.com (8.9.3/8.9.3) with ESMTP id JAA04971 for ; Fri, 16 Feb 2001 09:41:17 -0500 Message-ID: <3A8D3C04.3D81B5BA@candata.com> Date: Fri, 16 Feb 2001 09:41:09 -0500 From: Steve Meynell Organization: CanData X-Mailer: Mozilla 4.74 [en] (X11; U; Linux 2.2.5-15 i586) X-Accept-Language: en MIME-Version: 1.0 To: Postgresql Mailing List Subject: Help Retrieving Latest Record Content-Type: multipart/alternative; boundary="------------0C98608641A89F5AEFB1A40F" X-Archive-Number: 200102/289 X-Sequence-Number: 1481 --------------0C98608641A89F5AEFB1A40F Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 --------------0C98608641A89F5AEFB1A40F Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit 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
  --------------0C98608641A89F5AEFB1A40F--