Search Postgresql Archives

Re: Single Table Select With Aggregate Function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 3 Jan 2012, Tom Lane wrote:

You can do that type of thing using subqueries, eg

	select ... from mytab
	  where col = (select max(col) from mytab where ...)

  Thanks, Tom. That's what I thought I needed.

or if you don't mind a nonstandard construct, consider SELECT DISTINCT ON.
There's an example of how to use that in the SELECT reference page
(look for the weather-reports example).  In any case you're going to
have to consider what you want to have happen when there are multiple
occurrences of the maximum value.

  I'll look at that, too.

Much appreciated,

Rich

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux