pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alex Pilosov <alex@pilosoft.com>
To: Steve Meynell <steve@candata.com>
Cc: Postgresql Mailing List <pgsql-sql@postgresql.org>
Subject: Re: Help retrieving lastest record
Date: Fri, 16 Feb 2001 15:50:32 -0500 (EST)
Message-ID: <Pine.BSO.4.10.10102161549470.13453-100000@spider.pilosoft.com> (raw)
In-Reply-To: <3A8C4471.CFDF9937@candata.com>

Get an SQL book.

select * from basket 
where date=(select max(date) where fruit='Apples) 
and fruit='Apples';

On Thu, 15 Feb 2001, Steve Meynell wrote:

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




view thread (3+ messages)

Message-ID: <Pine.BSO.4.10.10102161549470.13453-100000@spider.pilosoft.com>
Permalink:  ../Pine.BSO.4.10.10102161549470.13453-100000@spider.pilosoft.com/
Also on:    postgresql.org/message-id/Pine.BSO.4.10.10102161549470.13453-100000@spider.pilosoft.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: alex@pilosoft.com, steve@candata.com
  Subject: Re: Help retrieving lastest record
  In-Reply-To: <Pine.BSO.4.10.10102161549470.13453-100000@spider.pilosoft.com>
  References: <3A8C4471.CFDF9937@candata.com> <Pine.BSO.4.10.10102161549470.13453-100000@spider.pilosoft.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox