Re: proposal - GROUPING SETS

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "PostgreSQL-development Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal - GROUPING SETS
Date: 2008-09-16 14:22:51
Message-ID: 162867790809160722g3d90abe2wf0da18b775f3ae6e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2008/9/16 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> writes:
>> select a, b from t group by grouping sets(a, b);
>
>> is same as:
>
>> select a, NULL from t group by a
>> union all
>> select NULL, b from t group by b;
>
> Really? That seems utterly bizarre, not to say pointless.
> You sure you read the spec correctly?

If GSi is an <ordinary grouping set>, then
A) Transform SL2 to obtain SL3, and transform HC to obtain HC3, as follows:
For every PCk, if there is no j such that PCk = GCRi,j, then make
the following
replacements in SL2 and HC:
I) Replace each <grouping operation> in SL2 and HC that
contains a <column ref-
erence> that references PCk by the <literal> 1 (one).
II) Replace each <column reference> in SL2 and HC that references PCk by
CAST ( NULL AS DTPCk )

if I understend it well, there is little bit different rules than
usual GROUP BY clause.

Is there different way, how to merge more different results? NULL
value is only one possible solution.

Pavel

>
> regards, tom lane
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2008-09-16 14:24:31 Re: per-table autovacuum configuration
Previous Message Alvaro Herrera 2008-09-16 14:11:49 Re: Subtransaction commits and Hot Standby