Re: Planning aggregates which require sorted or distinct

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gavin Sherry <swm(at)alcove(dot)com(dot)au>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Planning aggregates which require sorted or distinct
Date: 2007-01-20 07:05:47
Message-ID: 10346.1169276747@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gavin Sherry <swm(at)alcove(dot)com(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gurjeet Singh 2007-01-20 07:37:03 Re: [PATCHES] [HACKERS] [Fwd: Index Advisor]
Previous Message Dennis Bjorklund 2007-01-20 05:26:33 Re: savepoint improvements