何时使用GROUPING SETS,CUBE和ROLLUP
最近了解了用于在SQL Server多组集的定义GROUPING SETS,CUBE和ROLLUP。
我想问的是我们在什么情况下使用这些功能?使用它们和优点?
SELECT shipperid,YEAR(shippeddate) AS shipyear,COUNT(*) AS numordersFROM Sales.OrdersGROUP BY GROUPING SETS ( ( shipperid,YEAR(shippeddate) ),( shipperid ),( YEAR(shippeddate) ...