Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-21 Thread Daniel Verite
David Kerr wrote: > Well, an upgrade's not on tap for a few months. Until then i'll need to > figure out somethnig else. This may help: http://www.depesz.com/index.php/2007/08/17/rownum-anyone-cumulative-sum-in-on e-query/ or http://preview.tinyurl.com/mc4q6p Best regards, -- Daniel P

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-21 Thread David Kerr
On Wed, Oct 20, 2010 at 09:35:11PM -0700, Darren Duncan wrote: - Josh Kupershmidt wrote: - >On Wed, Oct 20, 2010 at 6:22 PM, David Kerr wrote: - >>I know I've seen posts on how to do this, but i can't seem to find them. - >> - >>I've got a data set - >> - >>A, B - >>A, C - >>A, D - >>[...] - >> -

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-21 Thread David Kerr
On Wed, Oct 20, 2010 at 10:32:15PM -0400, Josh Kupershmidt wrote: - On Wed, Oct 20, 2010 at 6:22 PM, David Kerr wrote: - > I know I've seen posts on how to do this, but i can't seem to find them. - > - > I've got a data set - > - > A, B - > A, C - > A, D - > [...] - > - > and so on - > - > and i'd

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-21 Thread Thomas Kellerer
Alban Hertroys, 21.10.2010 13:43: I'm currently using WebFOCUS at work and they have a LAST operator, referring to the value a column had in the last returned row. That's pretty good for stuff like this, so I wonder if it wouldn't be beneficial to have something like that in Postgres? Already t

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-21 Thread Alban Hertroys
On 21 Oct 2010, at 24:28, Raymond O'Donnell wrote: >> and i'd like to be able to wite a query that would result in >> >> 1,A,B >> 2,A,C >> 3,A,D >> [...] >> >> PG version is 8.3. >> >> Any ideas? > > You probably want generate_series(): > > http://www.postgresql.org/docs/8.3/static/function

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-20 Thread Darren Duncan
Josh Kupershmidt wrote: On Wed, Oct 20, 2010 at 6:22 PM, David Kerr wrote: I know I've seen posts on how to do this, but i can't seem to find them. I've got a data set A, B A, C A, D [...] and so on and i'd like to be able to wite a query that would result in 1,A,B 2,A,C 3,A,D [...] PG ve

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-20 Thread Josh Kupershmidt
On Wed, Oct 20, 2010 at 6:22 PM, David Kerr wrote: > I know I've seen posts on how to do this, but i can't seem to find them. > > I've got a data set > > A, B > A, C > A, D > [...] > > and so on > > and i'd like to be able to wite a query that would result in > > 1,A,B > 2,A,C > 3,A,D > [...] > >

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-20 Thread DM
create temp table dup_test (nm1 varchar(2),nm2 varchar(3)); insert into dup_test values ('A','A'),('A','B'),('A','C'),('B','A'),('B', 'B'),('B','C'); CREATE SEQUENCE dup_test_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; alter table dup_test add column dup_id

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-20 Thread David Kerr
On Wed, Oct 20, 2010 at 03:47:19PM -0700, DM wrote: - select generate_series(1,(select count(*) from tax)), country from tax; - - you should use braces around the sub select. - - Thanks - Deepak Table "public.test" Column | Type | Modifiers +--+

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-20 Thread David Kerr
On Wed, Oct 20, 2010 at 03:47:19PM -0700, DM wrote: - select generate_series(1,(select count(*) from tax)), country from tax; - - you should use braces around the sub select. - - Thanks - Deepak - Ah, great, thanks! Dave - On Wed, Oct 20, 2010 at 3:30 PM, David Kerr wrote: - - > On Wed, O

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-20 Thread DM
select generate_series(1,(select count(*) from tax)), country from tax; you should use braces around the sub select. Thanks Deepak On Wed, Oct 20, 2010 at 3:30 PM, David Kerr wrote: > On Wed, Oct 20, 2010 at 11:28:18PM +0100, Raymond O'Donnell wrote: > - On 20/10/2010 23:22, David Kerr wrote:

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-20 Thread David Kerr
On Wed, Oct 20, 2010 at 11:28:18PM +0100, Raymond O'Donnell wrote: - On 20/10/2010 23:22, David Kerr wrote: - >I know I've seen posts on how to do this, but i can't seem to find them. - > - >I've got a data set - > - >A, B - >A, C - >A, D - >[...] - > - >and so on - > - >and i'd like to be able to

Re: [GENERAL] Generate a dynamic sequence within a query

2010-10-20 Thread Raymond O'Donnell
On 20/10/2010 23:22, David Kerr wrote: I know I've seen posts on how to do this, but i can't seem to find them. I've got a data set A, B A, C A, D [...] and so on and i'd like to be able to wite a query that would result in 1,A,B 2,A,C 3,A,D [...] PG version is 8.3. Any ideas? You probab

[GENERAL] Generate a dynamic sequence within a query

2010-10-20 Thread David Kerr
I know I've seen posts on how to do this, but i can't seem to find them. I've got a data set A, B A, C A, D [...] and so on and i'd like to be able to wite a query that would result in 1,A,B 2,A,C 3,A,D [...] PG version is 8.3. Any ideas? Thanks Dave -- Sent via pgsql-general mailing lis