How can I use the crosstab() function?

Поиск
Список
Период
Сортировка
От Rob Richardson
Тема How can I use the crosstab() function?
Дата
Msg-id 67D108EDFAD3C148A593E6ED7DCB4BBDD840E666@RADCONWIN2K8PDC.radcon.local
обсуждение исходный текст
Ответы Re: How can I use the crosstab() function?  (Thom Brown <thom@linux.com>)
Список pgsql-general

Hello!

 

I am trying to use the crosstab() function in PostgreSQL 9.0 under Windows 7.  My table has three columns: a timestamp, a tag name and a tag value.  I am trying to generate a table that has one column for every distinct value in the tag name field.  Each row of the crosstab table will have the timestamp, plus values for every tag name that had a value recorded at that time.  Of course, many of the fields in each row will be null.

 

It seems to me that the crosstab() function will do exactly what I want, but I can’t get it to work.  If I try:

select * from

crosstab('select recorded_date, tag_name, value from plc_values')

as ct(recorded_date timestamp with time zone, tag_name text, tag_value text);

I get “function crosstab(unknown) does not exist”.

 

According to documentation, I think I need to add the tablefunc extension first.  But when I run

                create extension tablefunc;

I get a syntax error pointing to the word “extension”.

 

What haven’t I done?

 

Thank you very much.

 

RobR 

В списке pgsql-general по дате отправления:

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: Josh's Comments on Hstore / Jsonb
Следующее
От: Thom Brown
Дата:
Сообщение: Re: How can I use the crosstab() function?