From: | Thomas O'Connell <tfo(at)sitening(dot)com> |
---|---|
To: | Craig <postgresql(at)bryden(dot)co(dot)za> |
Cc: | "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Ranking Results |
Date: | 2005-09-14 14:51:46 |
Message-ID: | D35B0BF9-8B7E-442F-A679-11AC39784898@sitening.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sep 13, 2005, at 3:07 PM, Craig wrote:
> Hi
>
> I have a query that is grouping by 3 fields and returning a sum of
> another field. I would also like a further field to be returned
> that shows a ranking for the records based on the sum field. This
> should really only be a numbering of the rows returned, since I
> will do the ordering in an ORDER BY clause
>
> A Simplistic example:
>
> SELECT f1, f2, f3, sum(f4)
> FROM TableA
> GROUP BY f1, f2, f3
> ORDER BY f2,f1,f3
>
> Now I would like to add another field that simply return
> 1,2,3,4,5,etc.. for each row that is returned.
>
> Can this be done?
>
> Thanks
> Craig
If you're talking about row numbering rather than ranking, you can
try a temporary sequence:
http://archives.postgresql.org/pgsql-general/2005-02/msg01412.php
--
Thomas F. O'Connell
Co-Founder, Information Architect
Sitening, LLC
Strategic Open Source: Open Your i™
http://www.sitening.com/
110 30th Avenue North, Suite 6
Nashville, TN 37203-6320
615-469-5150
615-469-5151 (fax)
From | Date | Subject | |
---|---|---|---|
Next Message | philip johnson | 2005-09-14 15:00:33 | Re: XlogFlus error message |
Previous Message | William Leite Araújo | 2005-09-14 14:38:35 | TSearch2 snowball version error |