Search Postgresql Archives

Crosstab Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----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-----

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux