Re: crosstab

Поиск
Список
Период
Сортировка
От Aram Fingal
Тема Re: crosstab
Дата
Msg-id 09AE4623-B1E5-4F8D-AC55-EF5906A6411C@multifactorial.com
обсуждение исходный текст
Ответ на Re: crosstab  (Joe Conway <mail@joeconway.com>)
Ответы Re: crosstab  (Joe Conway <mail@joeconway.com>)
Re: crosstab  (Misa Simic <misa.simic@gmail.com>)
Список pgsql-general
On Sep 4, 2012, at 3:26 PM, Joe Conway wrote:

> On 09/04/2012 12:17 PM, Aram Fingal wrote:
>> On Sep 4, 2012, at 2:51 PM, Vincent Veyron wrote:
>>> see the documentation for Additional Supplied Modules, in your
>>> case tablefunc :
>>>
>>> http://www.postgresql.org/docs/9.1/static/tablefunc.html
>>
>> I evaluated tablefunc about a year and a half ago and found that it
>> was not what I wanted because you have to explicitly list what you
>> want the columns to be.  In some cases, there will be hundreds of
>> columns in the pivoted table.  The Reshape library in R can pivot
>> tables without you even knowing ahead of time how many columns there
>> are going to be.
>
> Sure, but you cannot return that reshaped table to postgres without
> specifying the list of columns explicitly. That is because of how
> postgres works internally and has nothing to do with whether you are
> using crosstab from tablefunc, PL/R, or some hand-coded SQL statement to
> build your crosstab.
>
> But certainly if you can do all your work on the reshaped table within
> the R environment, PL/R will be easier to use.


So, are you saying that if I do something like this:

copy(crosstab(source_sql, category_sql)) to '/output.csv' with csv;

Then I don't have to list what the columns are going to be?  In other words, I can skip the "AS (...)" clause which is
shownin the examples in the tablefunc documentation? 

-Aram

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

Предыдущее
От: Joe Conway
Дата:
Сообщение: Re: crosstab
Следующее
От: Joe Conway
Дата:
Сообщение: Re: crosstab