pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steve Meynell <steve@candata.com>
To: Joel Burton <jburton@scw.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Selecting Most Recent Row
Date: Wed, 13 Dec 2000 17:09:14 -0500
Message-ID: <3A37F38A.D52497C0@candata.com> (raw)
References: <3A37A5FF.26823.13E1C98@localhost>

Joel,
    Thank you very much.  I gave that a try and it worked perfectly.  It
definately was the distinct keyword I was missing.

Thanks Again,
Steve


Joel Burton wrote:

>
> Will DateStamp being the date of insertion? If so, is it that you want
> the record for the most recent (largest) datestamp for each
> batch_number?
>
> something like
>
> SELECT DISTINCT ON (batch_number) unique_key, datestamp,
> batch_number, instructions FROM widgets ORDER BY batch_number,
> datestamp desc;
>
> (sort by batch then by date (last first) and show the first (aka
> 'distinct') row, considering only the batch_number for distinctness)




view thread (3+ messages)

Message-ID: <3A37F38A.D52497C0@candata.com>
Permalink:  ../3A37F38A.D52497C0@candata.com/
Also on:    postgresql.org/message-id/3A37F38A.D52497C0@candata.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: steve@candata.com, jburton@scw.org
  Subject: Re: Selecting Most Recent Row
  In-Reply-To: <3A37F38A.D52497C0@candata.com>
  References: <3A37A5FF.26823.13E1C98@localhost> <3A37F38A.D52497C0@candata.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