pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Frank Morton <fmorton@base2inc.com>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Select Maximum Question
Date: Thu, 12 Aug 1999 19:01:56 -0400
Message-ID: <22978.934498916@sss.pgh.pa.us> (raw)
In-Reply-To: <00ef01bee4da$8d704060$8355e5ce@base2inc.com>

"Frank Morton" <fmorton@base2inc.com> writes:
> I want to do a select which only returns the highest revision
> level for each filename,

Try something like

	SELECT filename, max(revision) FROM table GROUP BY filename;

When you use GROUP BY, aggregate functions like max() are applied
separately over each group --- which is just what you want for this
problem.

			regards, tom lane



view thread (2+ messages)

Message-ID: <22978.934498916@sss.pgh.pa.us>
Permalink:  ../22978.934498916@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22978.934498916@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, fmorton@base2inc.com
  Subject: Re: [SQL] Select Maximum Question
  In-Reply-To: <22978.934498916@sss.pgh.pa.us>
  References: <00ef01bee4da$8d704060$8355e5ce@base2inc.com> <22978.934498916@sss.pgh.pa.us>

* 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