| From: | José María Terry Jiménez <jtj(at)tssystems(dot)net> | 
|---|---|
| To: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: Error in crosstab using date_trunc | 
| Date: | 2009-12-06 11:54:51 | 
| Message-ID: | 4B1B9B8B.2080809@tssystems.net | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
Scott Marlowe escribió:
> On Sat, Dec 5, 2009 at 12:11 PM, Jose Maria Terry Jimenez
> <jtj(at)tssystems(dot)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.
>
>   
Thank you very much. This worked, also worked with ' instead $outer$ BUT 
escaping the ' in minute with two of them  ' 'minute' '.
What does $outer$ or when i must use it?
Best,
Jose Maria
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Scanned with Copfilter Version 0.84beta3a (ProxSMTP 1.6)
AntiVirus: ClamAV 0.95.2/10115 - Sun Dec  6 09:37:09 2009
by Markus Madlener @ http://www.copfilter.org
| From | Date | Subject | |
|---|---|---|---|
| Next Message | José María Terry Jiménez | 2009-12-06 11:56:20 | Re: Error in crosstab using date_trunc | 
| Previous Message | José María Terry Jiménez | 2009-12-06 11:49:45 | Re: Error in crosstab using date_trunc |