Re: pivot functions with variable number of columns

From: Misa Simic <misa(dot)simic(at)gmail(dot)com>
To: punnoose <punnoose(dot)pj(at)dwisesolutions(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pivot functions with variable number of columns
Date: 2012-09-06 18:37:50
Message-ID: CAH3i69kyvE09SH42Vh+-UxTmWCJ1tiSC=eLg55m7U6WyLrHo3g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

That is one of most wanted features of PostgreSQL, what is not solved yet,,,

But it seems will be soon with introductions of Stored Procedures...

For now, you must "know" what result (columns) you expects...

So the only one option for now is to use Dynamic SQL - to build your query
dynamically based on data in your table (based on column what should be
pivoted)..

And then execute that query...

You can use your client side language to build SQL or inisde DB you could
make function what returns "text" as your Dynamic SQL and then execute it
from your client...

Kind Regards,

Misa

2012/9/6 punnoose <punnoose(dot)pj(at)dwisesolutions(dot)com>

> I want to have a pivot like function in which i should have variable number
> of columns.i went for crosstab but it doesnot support variable number of
> columns.Can any body suggest an alternative.like if i have a event at a
> particular time of the day like one at 02:35,11:34, then i should have
> column name 02:35,11:34.
> Please do help me.
> Punnoose
>
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/pivot-functions-with-variable-number-of-columns-tp5723013.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2012-09-06 18:40:28 Re: Moving several databases into one database with several schemas
Previous Message Bruce Momjian 2012-09-06 18:03:35 Re: return text from explain