Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group