Skip site navigation (1) Skip section navigation (2)

Re: generic crosstab ?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Andreas <maps(dot)on(at)gmx(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: generic crosstab ?
Date: 2012-04-25 03:46:37
Message-ID: CAFj8pRC7HmBQZ6wgW+T2-dPsG6yp3GYGwahJnA1+p4jy+CYqKw@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
Hello

try to use cursors

http://okbob.blogspot.com/2008/08/using-cursors-for-generating-cross.html

Regards

Pavel Stehule

2012/4/24 Andreas <maps(dot)on(at)gmx(dot)net>:
> Hi,
>
> is there a generic solution to dump the result of a query as a crosstab,
> when I can't know how many columns I will need?
>
> E.g. I get something like this:
>
> id, x
> 1,  a
> 1,  b
> 1,  c
> 2,  l
> 2,  m
>
>
> and I'd like to see it as:
>
> id,  x1,  x2,  x3,  .....  xn
> 1,   a,   b,   c,    null, .... null
> 2,   l,    m,  ....
>
> I fear the problem is I dont know n.
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql

In response to

pgsql-sql by date

Next:From: Trinath SomanchiDate: 2012-04-25 03:46:44
Subject: Re: How to group by similarity?
Previous:From: AndreasDate: 2012-04-24 22:37:06
Subject: Re: generic crosstab ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group