Re: [SQL] Select Maximum Question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Frank Morton" <fmorton(at)base2inc(dot)com>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Select Maximum Question
Date: 1999-08-12 23:01:56
Message-ID: 22978.934498916@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Frank Morton" <fmorton(at)base2inc(dot)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

Browse pgsql-sql by date

  From Date Subject
Next Message Moray McConnachie 1999-08-13 07:48:06 Re: [SQL] Searching Text Fields - Case Sensitive?
Previous Message disser 1999-08-12 15:59:00 Intentionally inserting duplicates without aborting