How to find the max value in a select? - Mailing list pgsql-general

From Erich
Subject How to find the max value in a select?
Date
Msg-id 200007310617.XAA02112@cyberpass.net
Whole thread Raw
List pgsql-general
I need to do something like this:

SELECT ...
FROM ...
WHERE ...
ORDER BY ...
COUNT 1

In other words, I want to find the one row matched by my WHERE clause
which is the maximum or minimum of all the rows that matched it.  I
could do the query above (ORDER BY...   COUNT 1), but does Postgres
optimize this, or does it find all the rows, sort them, and then take
off the top one?  Or is there some better way to do it?

Thanks,

e

pgsql-general by date:

Previous
From: "Oliver Elphick"
Date:
Subject: Re: Inheritance
Next
From: kumar1@home.com (Prasanth A. Kumar)
Date:
Subject: Re: How to find the max value in a select?