Re: Ranking Results

Поиск
Список
Период
Сортировка
От Thomas O'Connell
Тема Re: Ranking Results
Дата
Msg-id D35B0BF9-8B7E-442F-A679-11AC39784898@sitening.com
обсуждение исходный текст
Ответ на Ranking Results  ("Craig" <postgresql@bryden.co.za>)
Список 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:


--
Thomas F. O'Connell
Co-Founder, Information Architect
Sitening, LLC

Strategic Open Source: Open Your i™

110 30th Avenue North, Suite 6
Nashville, TN 37203-6320
615-469-5150
615-469-5151 (fax)

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: XlogFlus error message
Следующее
От: "philip johnson"
Дата:
Сообщение: Re: XlogFlus error message