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

Ranking?

From: "Sjors" <jkwast(at)freeler(dot)nl>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Ranking?
Date: 2003-09-25 15:45:35
Message-ID: 000801c3837c$100ff350$04a779d9@cc299057a (view raw or flat)
Thread:
Lists: pgsql-novice
Hi list,

Wondering if you could help me out here? I've got a table like this:

id    name    data
1    sully        567
2    sully        789
3    sully        456
4    denan       890
5    denan        678

now I want to have this:

id    name    data    rank
1    sully        567    2
2    sully        789    1
3    sully        456    3 
4    denan       890    1
5    denan        678    2

I'm think along the lines with count, something like this:

select id,name,data, (select count (names) from table as tmp where data.tmp > data.table) as rank

this (I know) is not correct. What would be? 

Greetings sjors

Responses

pgsql-novice by date

Next:From: Juan Francisco DiazDate: 2003-09-25 15:55:24
Subject: Function return type does not match
Previous:From: Godshall MichaelDate: 2003-09-25 15:32:25
Subject: Calling a function within a function - plpsql

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