SQL Training: Rollup and Cube(OLAP/SSAS)

--Rollup

select st.[Group],st.[Name],st.CountryRegionCode,
       sum(st.SalesYTD) current_year_sales,
   sum(st.SalesLastYear ) last_year_sales
from AdventureWorks2012.Sales.SalesTerritory as st
Group by st.[Group],st.[Name],st.CountryRegionCode
with Rollup

--cube

select st.[Group],st.[Name],st.CountryRegionCode,
       sum(st.SalesYTD) current_year_sales,
   sum(st.SalesLastYear ) last_year_sales
from AdventureWorks2012.Sales.SalesTerritory as st
Group by st.[Group],st.[Name],st.CountryRegionCode
with cube



These two functions are comparable to OLAP transactions.

Comments

Popular posts from this blog

SQL Training: Exercises on Stored Procedures and Functions

SQL Training: Exercise on Clauses,String and Mathematical functions,Date Time and Aggregate Functions

SQL Training:Exercises on Tables