Re: [SQL] Select Maximum Question - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] Select Maximum Question
Date
Msg-id 22978.934498916@sss.pgh.pa.us
Whole thread Raw
In response to Select Maximum Question  ("Frank Morton" <fmorton@base2inc.com>)
List pgsql-sql
"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


pgsql-sql by date:

Previous
From: disser@sdd.hp.com
Date:
Subject: Intentionally inserting duplicates without aborting
Next
From: "Moray McConnachie"
Date:
Subject: Re: [SQL] Searching Text Fields - Case Sensitive?