rollup

When to use GROUPING SETS, CUBE and ROLLUP

痴心易碎 提交于 2020-08-20 18:34:39
问题 I have recently learned about GROUPING SETS, CUBE and ROLLUP for defining multiple grouping sets in sql server. What I am asking is under what circumstances do we use these features ? What are the benefits and advantages of using them? SELECT shipperid, YEAR(shippeddate) AS shipyear, COUNT(*) AS numorders FROM Sales.Orders GROUP BY GROUPING SETS ( ( shipperid, YEAR(shippeddate) ), ( shipperid ), ( YEAR(shippeddate) ), ( ) ); SELECT shipperid, YEAR(shippeddate) AS shipyear, COUNT(*) AS

When to use GROUPING SETS, CUBE and ROLLUP

给你一囗甜甜゛ 提交于 2020-08-20 18:34:08
问题 I have recently learned about GROUPING SETS, CUBE and ROLLUP for defining multiple grouping sets in sql server. What I am asking is under what circumstances do we use these features ? What are the benefits and advantages of using them? SELECT shipperid, YEAR(shippeddate) AS shipyear, COUNT(*) AS numorders FROM Sales.Orders GROUP BY GROUPING SETS ( ( shipperid, YEAR(shippeddate) ), ( shipperid ), ( YEAR(shippeddate) ), ( ) ); SELECT shipperid, YEAR(shippeddate) AS shipyear, COUNT(*) AS

When to use GROUPING SETS, CUBE and ROLLUP

自古美人都是妖i 提交于 2020-08-20 18:34:07
问题 I have recently learned about GROUPING SETS, CUBE and ROLLUP for defining multiple grouping sets in sql server. What I am asking is under what circumstances do we use these features ? What are the benefits and advantages of using them? SELECT shipperid, YEAR(shippeddate) AS shipyear, COUNT(*) AS numorders FROM Sales.Orders GROUP BY GROUPING SETS ( ( shipperid, YEAR(shippeddate) ), ( shipperid ), ( YEAR(shippeddate) ), ( ) ); SELECT shipperid, YEAR(shippeddate) AS shipyear, COUNT(*) AS