On Thu, Apr 15, 2010 at 04:27:55AM -0700, Nafees Ur Rehman wrote:
> Hi,
>
> Whats is the syntax of grouping sets in monetdb? I am trying Select has_nurs,form,health,class,count(*) from nursery group by GROUPING SETS ((has_nurs,class),(form,class),(health,class))
> but it does not work
As far as I know, MonetDB does not support "GROUPING SETS" (yet?).
Hence, you'd have to rewrite your query to "UNION ALL" several queries that
do the individual groupings; e.g., your example:
SELECT has_nurs,form,health,class,count(*)
FROM nursery
GROUP BY GROUPING SETS ((has_nurs,class),(form,class),(health,class))
as follows:
SELECT has_nurs,form,health,class,count(*)
FROM nursery
GROPU BY has_nurs,class
UNION ALL
SELECT has_nurs,form,health,class,count(*)
FROM nursery
GROPU BY form,class
UNION ALL
SELECT has_nurs,form,health,class,count(*)
FROM nursery
GROPU BY
health,class;
Feel free to file a feature request in case you would like to see "GROUPING
SETS" in some future release of MonetDB/SQL (tough I cannot make any
promises right now ...)