Re: proposal - GROUPING SETS

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: proposal - GROUPING SETS
Дата
Msg-id 4136ffa0809160743l5880340bx65096606a89ee34b@mail.gmail.com
обсуждение исходный текст
Ответ на Re: proposal - GROUPING SETS  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: proposal - GROUPING SETS
Список pgsql-hackers
On Tue, Sep 16, 2008 at 3:02 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Pavel Stehule" <pavel.stehule@gmail.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?

I think that's basically right but IIRC you need another set of
parentheses so it's GROUPING SETS ((a),(b))

Basically grouping sets are a generalized form of rollup and cube. If
you did GROUPING SETS ((a),(a,b),(a,b,c)) you would get the same as
ROLLUP. And if you listed every possible subset of the grouping
columns it would be the equivalent of CUBE. But it lets you specify an
arbitrary subset of the combinations that CUBE would return.

-- 
greg


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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: Subtransaction commits and Hot Standby
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Autovacuum and Autoanalyze