Re: Re: Crosstab SQL Question - Mailing list pgsql-general

From Tom Lane
Subject Re: Re: Crosstab SQL Question
Date
Msg-id 5814.961136071@sss.pgh.pa.us
Whole thread Raw
In response to Re: Crosstab SQL Question  (Paul Condon <pecondon@quiknet.com>)
List pgsql-general
Paul Condon <pecondon@quiknet.com> writes:
> There are lots of issues with how one displays a crosstab which are not
> easily addressed within the context of RDBMS. I suggest the PostgreSQL
> team not plan to add crosstabs to PostgreSQL, ...

As near as I could see, the data that was being asked for was exactly
what you could get from a GROUP BY with multiple group columns:

    SELECT salesman, month, SUM(netprice) FROM salesorders
        GROUP BY salesman, month;

However the raw SQL output would look like

    Jim    Jan    1100
    Jim    Feb    1500
    ...
    Joe    Jan    120
    Joe    Feb    1200
    ...

so what's really wanted is a frontend to reformat this into a nicely
presented table.  I agree with Paul that that's not the task SQL is
designed for, whereas there are lots of data-visualization tools that
*are* designed for it.

> I have found a nice implementation of crosstabs in R, which is a
> system/language for statistical analysis, data display, and data
> plotting. <www.r-project.org>

Yup, R is cool (and free).  Anyone up for making an R-to-PGSQL
interface?

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: using max() aggregate
Next
From: Michael Meskes
Date:
Subject: Re: Crosstab SQL Question