"Kynn Jones" <kynnjo(at)gmail(dot)com> writes:
> Suppose I have a table T that has, among its columns, the fields X and Y,
> where Y is an integer, and multiple rows with the same value of X are
> possible. I want to select the rows corresponding to the greatest values of
> Y for each value of X.
You could use DISTINCT ON --- see the "weather reports" example in the
SELECT reference page. It's not standard SQL but will usually be faster
than solutions that use only standard features.
regards, tom lane
In response to
pgsql-general by date
|Next:||From: Casey Allen Shobe||Date: 2008-09-25 18:14:36|
|Subject: Re: Oracle and Postgresql|
|Previous:||From: zach cruise||Date: 2008-09-25 18:09:13|
|Subject: ease of use sync|