Re: getting the maximum from multiple returns

From: Bob Badour <bbadour_at_golden.net>
Date: Thu, 24 Apr 2003 12:04:46 -0400
Message-ID: <iwUpa.618$dX4.122720314_at_mantis.golden.net>


"Michael Sterling" <stermic_at_gw.co.jackson.mo.us> wrote in message news:f7359f44.0304240551.20a3a079_at_posting.google.com...
> i have a query where i'm attempting to select the maximum of the
> records returned. that is to say it will return multiple records with
> the same primary key

If it were a primary key, there could be no multiple records or tuples.

> and of those i want the one with the highest
> percentage as indicated in the sample of returned data below. what my

What you want is a quota query (TOP N)--in this case a TOP 1. Since SQL has no direct support for quota queries, all of the valid phrasings in SQL are rather complex.

I suggest using a scalar correlated subquery in your WHERE clause

ie. where perc_complete = ( select max(perc_complete)....) Received on Thu Apr 24 2003 - 18:04:46 CEST

Original text of this message