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

generic crosstab ?

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: generic crosstab ?
Date: 2012-04-24 20:01:31
Message-ID: (view raw or whole thread)
Lists: pgsql-sql

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.


pgsql-sql by date

Next:From: Samuel GendlerDate: 2012-04-24 20:08:23
Subject: Re: generic crosstab ?
Previous:From: Steve CrawfordDate: 2012-04-24 18:56:06
Subject: Re: [SQL] Simple way to get missing number

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