From: UEBAYASHI Masao <masao@nf.enveng.titech.ac.jp>
To: pgsql-sql@hub.org
Subject: Re: [SQL] numbered table?
Date: Wed, 15 Dec 1999 16:43:28 +0900
Message-ID: <19991215164328A.masao@nf.enveng.titech.ac.jp> (raw)
In-Reply-To: <19991210192346T.masao@nf.enveng.titech.ac.jp>
References: <19991210153410K.masao@nf.enveng.titech.ac.jp>
<19991210192346T.masao@nf.enveng.titech.ac.jp>
> I've found a topic near my question, ranking, in ``SQL FOR
> SMARTIES''. Thanks.
At last, I dumped this ranking method. Celko's suggestion was:
SELECT T1.attrib0, T1.attrib1,
(SELECT COUNT(DISTINCT attrib1)
FROM Table AS T2
WHERE (T2.attrib1 >= T1.attrib1)
AND (T2.attrib0 = T1.attrib0)) AS rank
FROM Table AS T1
WHERE rank <= :n;
or
SELECT T1.attrib0, T1.attrib1,
(SELECT COUNT(attrib1)
FROM Table AS T2
WHERE (T2.attrib1 >= T1.attrib1)
AND (T2.attrib0 = T2.attrib0)) AS rank
FROM Table AS T1
WHERE rank <= :n;
Unfortunately, neither don't run in PostgreSQL.
Masao
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: masao@nf.enveng.titech.ac.jp, pgsql-sql@hub.org
Subject: Re: [SQL] numbered table?
In-Reply-To: <19991215164328A.masao@nf.enveng.titech.ac.jp>
References: <19991210153410K.masao@nf.enveng.titech.ac.jp> <19991210192346T.masao@nf.enveng.titech.ac.jp> <19991215164328A.masao@nf.enveng.titech.ac.jp>
* 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