#009

Опубликовано: 14 Февраль 2026
на канале: Programming World
262
5

This is a SQL Server tutorial about ROLLUP & CUBE.

----------------------------------------------------------------------------------------------
ROLLUP: It will group the columns in hierarchy order of mention list in the ROLLUP query and produce the result.

eg.

ROLLUP(col1, col2, col3)

Grouping sets will be
(col1, col2, col3)
(col1, col2)
(col1)
()

NOTE: It always makes the group sets 1 greater than mentioned list count, above we mentioned 3 columns and we got the 4 group sets.
----------------------------------------------------------------------------------------------

CUBE: It will group the columns in all possible combinations of mentioned columns list in CUBE query and produce the result.

eg.

CUBE(col1, col2, col3)

Grouping sets will be
(col1, col2, col3)
(col1, col2)
(col2, col3)
(col1, col3)
(col1)
(col2)
(col3)
()

NOTE: It will make 2^N grouping sets from mentioned columns, as above we mentioned 3 columns as the groups forms the 8 sets

----------------------------------------------------------------------------------------------

Video Language: HINDI

Download Script :
https://bit.ly/2AWg9To

#SQLServer
#MSSQL
#SQL