From: | "Sjors" <jkwast(at)freeler(dot)nl> |
---|---|
To: | "Manfred Koizar" <mkoi-pg(at)aon(dot)at> |
Cc: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Ranking? |
Date: | 2003-09-25 23:37:10 |
Message-ID: | 001101c383bd$f11ad130$04a779d9@cc299057a |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi Manfred,
Sometimes the solution is right in front of you, but the cloud is to thick.
Thanks a lot, it worked like a charm. The reason I want this, is to have a
new type of index, so speed is not a issue and data file not big (just about
15000 records). I know, it's sounds silly.
Greetings Sjors
> >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
>
> SELECT id, name, data, (SELECT count(*) + 1
> FROM tbl AS tmp
> WHERE tmp.name = tbl.name
> AND tmp.data > tbl.data) AS rank
> FROM tbl;
>
> should get you going but might perform horribly without an index on
> name ...
>
> Servus
> Manfred
>
From | Date | Subject | |
---|---|---|---|
Next Message | sibusiso xolo | 2003-09-26 00:57:56 | installing 7.3.4 with java |
Previous Message | Tom Lane | 2003-09-25 23:03:34 | Re: Cache lookup error |