| From: | UEBAYASHI Masao <masao(at)nf(dot)enveng(dot)titech(dot)ac(dot)jp> |
|---|---|
| To: | pgsql-sql(at)hub(dot)org |
| Subject: | Re: [SQL] numbered table? |
| Date: | 1999-12-15 07:43:28 |
| Message-ID: | 19991215164328A.masao@nf.enveng.titech.ac.jp |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
> 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Patrick JACQUOT | 1999-12-15 10:37:45 | Re: [SQL] SQL'92 web resources |
| Previous Message | Tom Lane | 1999-12-15 06:57:07 | Re: [SQL] Search optimisation |