Re: [SQL] need ``row number``

Поиск
Список
Период
Сортировка
Искать
От
Greg Stark
Тема
Re: [SQL] need ``row number``
Дата
Msg-id
87ekkr9ziw.fsf@stark.xeocode.com
Ответ на
Список
Дерево обсуждения
Re: need ``row number`` "Ian Harding" <iharding@tpchd.org>
Re: need ``row number`` Karsten Hilbert <Karsten.Hilbert@gmx.net>
Re: need ``row number`` Tom Lane <tgl@sss.pgh.pa.us>
Re: [SQL] need ``row number`` Greg Stark <gsstark@mit.edu>
Tom Lane  writes:

> Karsten Hilbert  writes:
> > I am not convinced I'll need a SRF. I am not trying to
> > calculate something that isn't there yet. I am just trying to
> > join two views appropriately. I might have to employ some
> > variant of Celko's integer helper table but I'm not sure how
> > to proceed.
> 
> A fairly common hack for this is to use a sequence:
> 
> 	create temp sequence tseq;
> 	select nextval('tseq'), * from (select .... order by ...) ss;

But I thought she wanted to get the row number within a group. Not the row
number for the entire result set. A sequence can't do that. Or at least, I
suppose it could but it would be mighty strange to see setval() in a SELECT
query. And I can't think of how to detect the level break in a select query
either.

-- 
greg
В списке pgsql-general по дате отправления
От: Robert Fitzpatrick
Дата:
От: Jerry LeVan
Дата:
FAQ