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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-novice by date

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