oracle rank() over partition by queries

From: Ruben Gouveia <rgouveia(at)2wire(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: oracle rank() over partition by queries
Date: 2008-08-21 20:42:36
Message-ID: 1219351357.27860.5.camel@dina2.dhcp.2wire.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Does postgreSQL have an equivalent of the Oracle's "rank() over by
partition"?

Here's what i have so far but it doesn't work:

select id,
sum(case when key = 5 then 1 else 0 end),
sum(case when key = 6 then 1 when key = 7 then 1 else 0 end),
sum(case when l.status = 6 then cost when key = 7 then cost else
0 end),
RANK() OVER (ORDER BY sum(case when key = 6 then 1 when key = 7
then 1 else 0 end) DESC) AS RANK
from mytable
group by id

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Travis Smith 2008-08-21 20:49:48 Re: [ADMIN] Query performance difference
Previous Message Robert Treat 2008-08-21 20:35:17 Re: New to postgres -' how to' tips needed