Re: Planning aggregates which require sorted or distinct - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Planning aggregates which require sorted or distinct
Date
Msg-id 10346.1169276747@sss.pgh.pa.us
Whole thread Raw
In response to Re: Planning aggregates which require sorted or distinct  (Gavin Sherry <swm@alcove.com.au>)
Responses Re: Planning aggregates which require sorted or distinct  (Markus Schiltknecht <markus@bluegap.ch>)
Re: Planning aggregates which require sorted or distinct  (Gavin Sherry <swm@alcove.com.au>)
List pgsql-hackers
Gavin Sherry <swm@alcove.com.au> writes:
> We want to answer the following: for each employee: what is their rank in
> terms of salary and what is their rank in terms of age. This query
> answers that:

> select empno, rank() over (order by salary) as srank,
>   rank() over (order by age) as arank
>   from employees order by empno;

Eeek.  This seems like the worst sort of action-at-a-distance.  How does
rank() know what value it's supposed to report the rank of?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Dennis Bjorklund
Date:
Subject: Re: savepoint improvements
Next
From: Markus Schiltknecht
Date:
Subject: Re: Planning aggregates which require sorted or distinct