Re: [patch] Proposal for \crosstabview in psql

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Daniel Verite <daniel(at)manitou-mail(dot)org>, Teodor Sigaev <teodor(at)sigaev(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [patch] Proposal for \crosstabview in psql
Date: 2016-02-17 02:32:47
Message-ID: 56C3DBCF.1030007@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2/11/16 4:21 AM, Dean Rasheed wrote:
> Thinking about this some more though, perhaps*sorting* the columns is
> the wrong way to be thinking about it. Perhaps a better approach would
> be to allow the columns to be*listed* (optionally, using a separate
> query). Something like the following (don't get too hung up on the
> syntax):
>
> SELECT name,
> to_char(date, 'Mon') AS month,
> sum(amount) AS amount
> FROM invoices
> GROUP BY 1,2
> ORDER BY name
> \crosstabview cols = (select to_char(d, 'Mon') from
> generate_series('2000-01-01'::date, '2000-12-01', '1 month') d)

My concern with that is that often you don't know what the columns will
be, because you don't know what exact data the query will produce. So to
use this syntax you'd have to re-create a huge chunk of the original
query. :(
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2016-02-17 02:43:10 Re: proposal: enhancing slow query log, and autoexplain log about waiting on lock before query exec time
Previous Message Jim Nasby 2016-02-17 02:19:55 Commitfest Bug (was: Re: Reusing abbreviated keys during second pass of ordered [set] aggregates)