X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 771C3D1CAB0 for ; Tue, 4 May 2004 10:42:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 63704-05 for ; Tue, 4 May 2004 10:42:25 -0300 (ADT) Received: from p15124592.pureserver.info (p15124592.pureserver.info [217.160.181.164]) by svr1.postgresql.org (Postfix) with ESMTP id BE8E1D1F025 for ; Tue, 4 May 2004 10:42:20 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by p15124592.pureserver.info (Postfix) with ESMTP id CF71F1795A for ; Tue, 4 May 2004 15:42:22 +0200 (CEST) Received: from webmail.mk-os.de (localhost [127.0.0.1]) by p15124592.pureserver.info (Postfix) with SMTP id 3711917959 for ; Tue, 4 May 2004 15:42:21 +0200 (CEST) Received: from blueice4n1.de.ibm.com ([195.212.29.187]) (SquirrelMail authenticated user martin) by webmail.mk-os.de with HTTP; Tue, 4 May 2004 15:42:21 +0200 (CEST) Message-ID: <16616.195.212.29.187.1083678141.squirrel@webmail.mk-os.de> In-Reply-To: <003e01c42fa9$5677b240$4f00a8c0@MIDDINKS> References: <003e01c42fa9$5677b240$4f00a8c0@MIDDINKS> Date: Tue, 4 May 2004 15:42:21 +0200 (CEST) Subject: Re: Rank From: "Martin Knipper" To: pgsql-sql@postgresql.org Reply-To: martin@mk-os.de User-Agent: SquirrelMail/1.4.1 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 Importance: Normal X-Virus-Scanned: by AMaViS at MK-OS X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=PRIORITY_NO_NAME X-Spam-Level: X-Archive-Number: 200405/46 X-Sequence-Number: 17760 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