pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Martin Knipper <martin@mk-os.de>
To: pgsql-sql@postgresql.org
Subject: Re: Rank
Date: Tue, 4 May 2004 15:42:21 +0200 (CEST)
Message-ID: <16616.195.212.29.187.1083678141.squirrel@webmail.mk-os.de> (raw)
In-Reply-To: <003e01c42fa9$5677b240$4f00a8c0@MIDDINKS>
References: <003e01c42fa9$5677b240$4f00a8c0@MIDDINKS>

Hey,

Muhyiddin A.M Hayat sagte:
>
> Dear All,
>
> I Have below table
>
>  id | site_name | point
> ----+-----------+-------
>   1 | Site A    |    40
>   2 | Site B    |    90
>   3 | Site D    |    22
>   4 | Site X    |    98
>
>  Would like to calc that Rank for each site, and look like
>
>
>
>  id | site_name | point | rank
> ----+-----------+-------+------
>   1 | Site A    |    40 |    3
>   2 | Site B    |    90 |    2
>   3 | Site D    |    22 |    4
>   4 | Site X    |    98 |    1
>
> What can I do to get result like that

create temporary sequence ranking;
select *,nextval('ranking') as rank from yourTable order by site_name asc;

Greetins,
Martin Knipper

-- 
Martin Knipper
knipper@mk-os.de
http://www.mk-os.de



view thread (7+ messages)  latest in thread

Message-ID: <16616.195.212.29.187.1083678141.squirrel@webmail.mk-os.de>
Permalink:  ../16616.195.212.29.187.1083678141.squirrel@webmail.mk-os.de/
Also on:    postgresql.org/message-id/16616.195.212.29.187.1083678141.squirrel@webmail.mk-os.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: martin@mk-os.de
  Subject: Re: Rank
  In-Reply-To: <16616.195.212.29.187.1083678141.squirrel@webmail.mk-os.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox