Re: Error in crosstab using date_trunc

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: Error in crosstab using date_trunc
Дата
Msg-id dcc563d10912051913qde052d7gd25cef544b1ebf0b@mail.gmail.com
обсуждение исходный текст
Ответ на Error in crosstab using date_trunc  (Jose Maria Terry Jimenez <jtj@tssystems.net>)
Ответы Re: Error in crosstab using date_trunc  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Re: Error in crosstab using date_trunc  (José María Terry Jiménez <jtj@tssystems.net>)
Список pgsql-general
On Sat, Dec 5, 2009 at 12:11 PM, Jose Maria Terry Jimenez
<jtj@tssystems.net> wrote:
> Hello all,
>
> I'm trying to do a crosstab from data that row names are times.
>
> These times are timestamps and  i  want to  use they truncating to minutes
>  this works for me:
>
> select distinct date_trunc('minute',"timestamp") as "timestamp" from
> historico order by "timestamp";
>
> Getting times "normalized" without seconds.
>
> If i do a crosstab using that date_trunc function i get errors. If i do:
>
> select *
> from crosstab
> (
> 'select date_trunc('minute',"timestamp") as "timestamp",remota,valor from
> historico order by 1,2'
> )
> as
> (anet timestamp without time zone,
> re1 numeric,
> re2 numeric,
> re3 numeric
> )
> ;

Looks like an escaping issue. Try replacing your outer ' with $outer$
or something like that:

select *
from crosstab
(
$outer$ select date_trunc('minute',"timestamp") as "timestamp",remota,valor from
historico order by 1,2 $outer$
)
as
(anet timestamp without time zone,
re1 numeric,
re2 numeric,
re3 numeric
)
;

And see if that helps.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: FATAL: no pg_hba.conf entry for host “::1”
Следующее
От: Sim Zacks
Дата:
Сообщение: Re: numeric cast oddity