pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Stark <gsstark@mit.edu>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Karsten Hilbert <Karsten.Hilbert@gmx.net>
Cc: pgsql-general@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] need ``row number``
Date: 24 Sep 2004 16:34:47 -0400
Message-ID: <87ekkr9ziw.fsf@stark.xeocode.com> (raw)
In-Reply-To: <21339.1096035613@sss.pgh.pa.us>
References: <s1530b77.094@mail.tpchd.org>
	<20040924092117.A1195@hermes.hilbert.loc>
	<21339.1096035613@sss.pgh.pa.us>

Tom Lane <tgl@sss.pgh.pa.us> writes:

> Karsten Hilbert <Karsten.Hilbert@gmx.net> 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




view thread (6+ messages)  latest in thread

Message-ID: <87ekkr9ziw.fsf@stark.xeocode.com>
Permalink:  ../87ekkr9ziw.fsf@stark.xeocode.com/
Also on:    postgresql.org/message-id/87ekkr9ziw.fsf@stark.xeocode.com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gsstark@mit.edu, tgl@sss.pgh.pa.us, Karsten.Hilbert@gmx.net, pgsql-general@postgresql.org
  Subject: Re: [SQL] need ``row number``
  In-Reply-To: <87ekkr9ziw.fsf@stark.xeocode.com>

* 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