السلام عليكــم ورحمـة الله وبركاتــه
أنا مبتدئة في SQL SERVER2000
وأواد أن أعرف الفرق ما بين ROLLUP و CUBE و GROUPING
ولكم جزيل الشكر
السلام عليكــم ورحمـة الله وبركاتــه
أنا مبتدئة في SQL SERVER2000
وأواد أن أعرف الفرق ما بين ROLLUP و CUBE و GROUPING
ولكم جزيل الشكر
hey , i will start with grouping and then rollup and cube
group by clause used to get sub-totals, select and group by closely integrated: each item in select list must be single-valued per group, and select clause may only contain:
column names
aggregate functions
constants
expression involving combinations of the above.
All column names in select list must appear in group by clause unless name is used only in an aggregate function.
If where is used with group by, where is applied first, then groups are formed from remaining rows satisfying predicate.
roll up This group by operation is used to produce subtotals at any level of aggregation needed. These subtotals then "roll up " into a grand total, according items listed in the group by expression.
cube is similar to roolup. The difference is that cube allows you to take specified set of grouping columns and create subtotals for all possible combination's of them.
The cube operation calculates all levels of subtotals on horizontal lines across spreadsheets of output and create cross-tab summaries on multiple vertical columns in those spreadsheets.
The result is a summary that shows subtotals for every combination of columns in the group by clause.
For further information your free to comment
Examples will inserted if ask for it ( sorry, but i have no time now!!)
تم تعديل هذه المشاركة بواسطة White Wolf في 18 يناير 2009 في 12:57
just for demonstration purposes i would add this
group by rollup(col1,col2)=grouping by co1,col2 AND group the result by col1
group by cube(col1,col2)=grouping by col1,col2 AND group the result by col1,AND group the result by col2