pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas <maps.on@gmx.net>
To: pgsql-sql@postgresql.org
Subject: generic crosstab ?
Date: Tue, 24 Apr 2012 22:01:31 +0200
Message-ID: <4F97069B.7020303@gmx.net> (raw)

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.



view thread (8+ messages)  latest in thread

Message-ID: <4F97069B.7020303@gmx.net>
Permalink:  ../4F97069B.7020303@gmx.net/
Also on:    postgresql.org/message-id/4F97069B.7020303@gmx.net

 · 

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: maps.on@gmx.net
  Subject: Re: generic crosstab ?
  In-Reply-To: <4F97069B.7020303@gmx.net>

* 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