Received: from tidal.ipinc.com (tidal.ipinc.com [199.245.188.85]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f1GLo9x70734 for ; Fri, 16 Feb 2001 16:50:09 -0500 (EST) (envelope-from jliang@tidal.ipinc.com) Received: from localhost (jliang@localhost) by tidal.ipinc.com (8.9.3/8.9.3) with ESMTP id NAA71084; Fri, 16 Feb 2001 13:49:16 -0800 (PST) (envelope-from jliang@tidal.ipinc.com) Date: Fri, 16 Feb 2001 13:49:16 -0800 (PST) From: Jie Liang To: Steve Meynell cc: Postgresql Mailing List Subject: Re: Help Retrieving Latest Record In-Reply-To: <3A8D3C04.3D81B5BA@candata.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200102/296 X-Sequence-Number: 1490 Subquery will do: select * from basket where Date in (select max(Date) from basket); Jie LIANG St. Bernard Software Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 jliang@ipinc.com www.stbernard.com www.ipinc.com On Fri, 16 Feb 2001, Steve Meynell wrote: > 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 > > >