Sunday, April 18, 2010

Difference between Rollup and Cube

You can use the CUBE and ROLLUP operators to generate summary information in a query. A CUBE operator generates a result set that shows the aggregates for all combinations of values in the selected columns. A ROLLUP operator generates a result set showing the aggregates for a hierarchy of values in the selected columns. Both the CUBE and ROLLUP operators return data in relational form.

The CUBE operator generates a multidimensional cube result set. A multidimensional cube is an expansion of fact data, or the data that records individual events.
This expansion is based on columns that the user wants to analyze. These columns are called dimensions. A cube is a result set that contains a cross tabulation of all the possible combinations of the dimensions.

The CUBE operator is specified in the GROUP BY clause of a SELECT statement. The select list contains the dimension columns and aggregate function expressions. The GROUP BY specifies the dimension columns by using the WITH CUBE keywords.
The result set contains all possible combinations of the values in the dimension columns, together with the aggregate values from the underlying rows that match that combination of dimension values.

The ROLLUP operator is useful in generating reports that contain aggregate values. The ROLLUP operator generates a result set that is similar to the result set generated by the CUBE operator.

However, the difference between the CUBE and ROLLUP operator is that the CUBE generates a result set that shows the aggregates for all combinations of values in the selected columns. By contrast, the ROLLUP operator returns only the specific result set.
The ROLLUP operator generates a result set that shows the aggregates for a hierarchy of values in the selected columns. Also, the ROLLUP operator provides only one level of summarization, for example, the cumulative running sum in a table.

30 comments:

  1. 外表往往與事實本身不符,世人卻容易被表面裝飾所欺騙了..................................................

    ReplyDelete
  2. 在你一無所有的時候 是誰在陪伴你 他便是你最重要的人 ............................................................

    ReplyDelete
  3. 被人揭下面具是一種失敗,自己揭下面具卻是種勝利。............................................................

    ReplyDelete
  4. 旁觀自己的悲傷是解脫,主觀自己的悲傷是更加悲傷..............................

    ReplyDelete
  5. 生存乃是不斷地在內心與靈魂交戰;寫作是坐著審判自己。......................................................................

    ReplyDelete
  6. Hi

    I read this post two times.

    I like it so much, please try to keep posting.

    Let me introduce other material that may be good for our community.

    Source: Web interview questions

    Best regards
    Henry

    ReplyDelete

 
Locations of visitors to this page