Re: dynamic columns in a query

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: dynamic columns in a query
Date: 2009-06-11 07:53:41
Message-ID: 20090611075341.GC16593@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

In response to Jyoti Seth :
> Hi All,
>
> Is there any way in postgres to write a query to display the result in
> matrix form. (where column names are dynamic)
>
> For eg.
>
>
> Employee Name Client1 Client2 Client3 Client4
> Emp1 100 102 90 23
> Emp2 56 0 23 98
> Emp3 34 45 76 0
>
>
> Here Client1, Client2... are the values from the database.

There is a contrib-modul, tablefunc. It contains a crosstab-function.
Maybe this can help you. Other solution: write a function in plpgsql and
build a string that contains your query, and EXECUTE that string.

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Pavel Stehule 2009-06-11 08:54:39 Re: dynamic columns in a query
Previous Message Jyoti Seth 2009-06-11 07:42:06 dynamic columns in a query