tablefunc and crosstab

From: Vincent Bernat <bernat(at)luffy(dot)cx>
To: pgsql-general(at)postgresql(dot)org
Subject: tablefunc and crosstab
Date: 2008-01-02 16:56:18
Message-ID: fd870c8f783e16b8b1f9a460b3cd83fa@imap.luffy.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi !

I am trying to use crosstab function from tablefunc.

SELECT * from crosstab('select date, source, name, value FROM cth ORDER by
1', 'select distinct name from cth order by 1') AS ct(date timestamp,
source text, val1 text, val2 text, val3 text, val4 text, val5 text);

The content of the table that I get is fine. However, I would like to get
appropriate names instead of arbitrary 'val1', 'val2', ...

Is it possible to rename the table columns with the result of 'select
distinct name from cth order by 1' ?

Thanks.

Browse pgsql-general by date

  From Date Subject
Next Message Jan Sunavec 2008-01-02 17:03:48 tsearch2 headline options
Previous Message Pavel Stehule 2008-01-02 16:42:53 Re: [HACKERS] Slow count(*)