From: | David Blewett <david(at)dawninglight(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | David Fetter <david(at)fetter(dot)org> |
Subject: | Crosstab Question |
Date: | 2007-08-09 00:23:40 |
Message-ID: | 46BA5E8C.9020708@dawninglight.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi All:
I'm building an application along the lines of the questionnaire
design on varlena.com [1], with slight modifications. In my design,
there's a table called chartversionquestion that collects different
questions into a bundle to create the questionnaire.
Using a view [2] very similar to the one on varlena, I pull all the
data from the value tables into one long list (cast to text). I
would like to be able to create a crosstab from this view such that
the short question name becomes a column header, with the related
value underneath.
Since the number of questions to be pivoted will vary per
questionnaire the method should accept a number of columns
parameter. The crosstab in the tablefunc contrib module expects the
columns to be explicitly identified before hand. I suppose it could
be possible to write a simple function to wrap the crosstab_n_cols
functions to be able to return a variable number, but that seems
hackish. Are there any other alternatives?
David Blewett
[1] http://www.varlena.com/GeneralBits/110.php
[2] http://www.varlena.com/varlena/GeneralBits/Tidbits/QnA/views.sql
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGul6MZmlc6wNjtLYRCA5hAJ9fSHjNI5gQs/eqZ85bHl4ZrGWG3ACfbEnG
zo1KFvZL8LraBESRySyVryg=
=w1Z8
-----END PGP SIGNATURE-----
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Ribe | 2007-08-09 00:27:33 | Re: Take your postgresSql on the road, and live to tell of it. |
Previous Message | Martijn van Oosterhout | 2007-08-09 00:14:24 | Re: Reordering columns, will this ever be simple? |