On Tue, Sep 16, 2008 at 3:02 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > "Pavel Stehule" <[EMAIL PROTECTED]> 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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers