As an alternative to the hierarchical grouping pattern provided by the ROLLUP clause, you can also create a data cube, that is, an ndimensional summarization of the input using every possible combination of GROUP BY expressions, using the CUBE clause. The CUBE clause results in a product set of all possible combinations of elements from each set of values. This can be very useful for complex data analysis.
If there are n GROUPING expressions of the form (X_{1},X_{2}, ...,X_{n}) in a CUBE clause, then CUBE generates 2^{n} grouping sets as:
{(), (X_{1}), (X_{1},X_{2}), (X_{1},X_{2},X_{3}), ... , (X_{1},X_{2},X_{3}, ...,X_{n}), (X_{2}), (X_{2},X_{3}), (X_{2},X_{3},X_{4}), ... , (X_{2},X_{3},X_{4}, ... , X_{n}), ... , (X_{n})}. 
Discuter à propos de cette page dans DocCommentXchange.

Copyright © 2012, iAnywhere Solutions, Inc.  SQL Anywhere 12.0.1 