Re: select a ranking - Mailing list pgsql-general

From Janning Vygen
Subject Re: select a ranking
Date
Msg-id 200207190954.g6J9snX29715@janning.planwerk6.local
Whole thread Raw
In response to Re: select a ranking  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: select a ranking  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-general
Am Freitag, 19. Juli 2002 02:41 schrieb Martijn van Oosterhout:
> On Thu, Jul 18, 2002 at 03:29:10PM +0200, Janning Vygen wrote:
>
> > i do some ordering on a table and need a ranking by points from a
> > table with names and points
>
> > is there an easier way to create a ranking?
>
> Yep, in the presentation tool. Pseudo-code is:
>
> For each row in result
>   print rownumber
>   print contents of row

this wont work because the ranking is not equal to the rownumber.
there are very often two second places. and there might be a
complicated logic to the ordering. there might be many columns
affected to to the ordering in sql.

the presentation tool can just number the rows, but it cant decide
easily if there are two second places. in sport rankings you have
often more than five ordering parameters and you still can have two
second places. So the presentation tool needs to know this ordering
logic to decide how to do the ranking. if there are changes in
ranking/ordering logic, i need to update all my presentation
clients...

> Why do you want to do this in SQL when it's clearly not the right
> place for it?

but you do the ordering in sql anyway. it would be just fine to add a
column with the ranking.

kind regards,
janning

pgsql-general by date:

Previous
From: csernazs@freemail.hu (Cserna Zsolt)
Date:
Subject: sequence scan, but indexed tables
Next
From: "Christian Lübeck"
Date:
Subject: References for PostgreSQL