The Anubhav portal was launched in March 2015 at the behest of the Hon'ble Prime Minister for retiring government officials to leave a record of their experiences while in Govt service .
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
In SQL Server, CUBE is used in
GROUP BYto generate all possible combinations of aggregations across multiple columns.Simple Meaning
Syntax
Example
Suppose you have sales data:
Query:
Output Explained
CUBE will generate:
Result:
Key Point
NULLmeans total (aggregation)Query Using CUBE
Understanding
(Region, Product)→ Normal grouping(Region, NULL)→ Total per Region(NULL, Product)→ Total per Product(NULL, NULL)→ Overall totalDifference from ROLLUP
When to Use
Use CUBE when you need:
One-Line Summary