Re: Help Retrieving Latest Record - Mailing list pgsql-sql

From Michael Fork
Subject Re: Help Retrieving Latest Record
Date
Msg-id Pine.BSI.4.21.0102161529480.26187-100000@glass.toledolink.com
Whole thread Raw
In response to Help Retrieving Latest Record  (Steve Meynell <steve@candata.com>)
List pgsql-sql
SELECT * FROM basket ORDER BY date desc LIMIT 1;
and
SELECT * FROM basket WHERE fruit = 'apple' ORDER BY date desc LIMIT 1;

Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio

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
> 
> 
> 



pgsql-sql by date:

Previous
From: Roberto Mello
Date:
Subject: Re: Help Retrieving Latest Record
Next
From: Andrew Perrin
Date:
Subject: Re: Help retrieving lastest record