Duration 7:42

Cube in SQL Server

109 355 watched
0
739
Published 22 Sep 2015

group by cube in sql server 2008 cube group by sql sql server group by cube example sql server cube group by Cube() in SQL Server produces the result set by generating all combinations of columns specified in GROUP BY CUBE(). Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help. /channel/UC7sEwIXM_YfAMyonQCrGfWA/ Let us understand Cube() in SQL Server with examples. Write a query to retrieve Sum of Salary grouped by all combinations of the following 2 columns as well as Grand Total. Country, Gender Using Cube with Group By SELECT Country, Gender, SUM(Salary) AS TotalSalary FROM Employees GROUP BY Cube(Country, Gender) --OR SELECT Country, Gender, SUM(Salary) AS TotalSalary FROM Employees GROUP BY Country, Gender with Cube The above query is equivalent to the following Grouping Sets query. SELECT Country, Gender, SUM(Salary) AS TotalSalary FROM Employees GROUP BY GROUPING SETS ( (Country, Gender), (Country), (Gender), () ) The above query is equivalent to the following UNION ALL query. While the data in the result set is the same, the ordering is not. Use ORDER BY to control the ordering of rows in the result set. SELECT Country, Gender, SUM(Salary) AS TotalSalary FROM Employees GROUP BY Country, Gender UNION ALL SELECT Country, NULL, SUM(Salary) AS TotalSalary FROM Employees GROUP BY Country UNION ALL SELECT NULL, Gender, SUM(Salary) AS TotalSalary FROM Employees GROUP BY Gender UNION ALL SELECT NULL, NULL, SUM(Salary) AS TotalSalary FROM Employees Text version of the video http://csharp-video-tutorials.blogspot.com/2015/09/cube-in-sql-server.html Slides http://csharp-video-tutorials.blogspot.com/2015/09/cube-in-sql-server_22.html All SQL Server Text Articles http://csharp-video-tutorials.blogspot.com/p/free-sql-server-video-tutorials-for.html All SQL Server Slides http://csharp-video-tutorials.blogspot.com/p/sql-server.html All Dot Net and SQL Server Tutorials in English /user/kudvenkat/playlists?view=1&sort=dd All Dot Net and SQL Server Tutorials in Arabic /c/KudvenkatArabic/playlists

Category

Show more

Comments - 49
  • @
    @Partap7799 years ago I have no words to express my gratitude to you, i am 0 to hero in sql after watching your sql videos series! 31
  • @
    @manishdubey86468 years ago Realyall videos are awesome. I have seen all and implement in my project. Very clearly understanding. Also i have shared multiple people who doesn' t know about sql. Multiple friends got a job only credit goes to your videos. ...Expand 1
  • @
    @962tushar4 years ago Have been trying to see what a cube looks like for so long. Finally found it. This helps me get dimensional modeling. Thanks. 1
  • @
    @FlareSoul695 years ago I am a sr analyst now. Making 100k+. All due to watching venkat' s videos several years ago. This man is a blessing and his videos are top notch! 6
  • @
    @vinothchinnasamy19127 years ago One of the best tutorials i have ever watched. Thanks a lot. Keep up the good work.
  • @
    @88spaces5 years ago Great insight into cubes and groupings. It helped me a lot. Thank you.
  • @
    @charliegordon137 years ago Great description of an incredibly complicated subject. Thanks for putting in the time.
  • @
    @sksingh7638 years ago You are the best, i really appreciate you sharing this video with you. Wonderful!
  • @
    @krzysztofs85357 years ago Thank u very much for your work. I' m the greatest fan of your tutorial. God bless you! 1
  • @
    @muhammadrehbarsheikh84989 years ago Thanks venkat sir. Excellent explanation. Go ahead. God bless you! 1
  • @
    @saadrouane65215 years ago Great video easy to follow through and comprehend! Thank you.
  • @
    @bouchrab54344 years ago This videos are still so helpful! There is always something to learn and he' s the only one i truly understand to be honest!
    thank you very much teacher:
  • @
    @avinashmamidi9 years ago Sir,
    could you please make similar videos for ssis, ssrs and ssas.
    9
  • @
    @learnwithharry89718 years ago This is the best explanation i' ve ever seen, thank you.
  • @
    @yoanperez1722 years ago Excellent video, very clear, thank you!
  • @
    @jcsrmpras9 years ago Hi sir, this is prasanna with the help of your video tutorials. I learned dotnet and sql. They helped me in clearing my interview. Im appointed as a dot . ...Expand 4
  • @
    @ushareddy33237 months ago Really thanks for your efforts its really useful u covered every topic. I am grateful to you sir.
  • @
    @Advanium7 years ago Thank you! Now i know what a cube is and how to even create one in several different ways, sweet!
  • @
    @wadungalungasertotin9 years ago Hi, do you have any material related to spatial data bases? 2
  • @
    @367958115 years ago Cool, for 5 min, i became smarter for one more command. Thx.
  • @
    @guillifr5 years ago Great explanation! Step by step to the point!
  • @
    @michaelnewman96459 years ago A brilliant series. Thank you. Have you any intention of producing a tutorial on how to insert images into sql server? 1
  • @
    @JohnWaclawski5 years ago Is the database you use available for download? Or is it one of the adventureworks databases? If so, which one?
    thank you! I always find something useful in your videos. Keep up the great work!
  • @
    @tannertucker227 years ago Some of the best tutorials that i have seen! What is the difference between rollup and cube please? Thank you.
  • @
    @ashishrao56359 years ago Hi, could you also explain how to us red gate s/w for transferring data from one server to another. 1
  • @
    @JohnWaclawski4 years ago I know this is a fairly old video, but any chance we can get the sample database you were using?
    thank you for all you do. I' ve watched many edit: funny but i watched this video 4 months ago & commented on it then too. Still looking for the sample db you used. ...Expand
  • @
    @shrikant13115 years ago Hi sir, can you please make similar videos for msbi like ssis, ssrs and ssas classes.
  • @
    @Md3081115 years ago Hi kudvenkat hope you are doing good
    can you please upload videos on ssas, ssrs and ssis as there are no. Of videos in u tube but no one clarify, understand better then you.
  • @
    @SanjayKumar-yh8fd3 years ago Bhut dhanyabad guru ji padane ki liye, dasi tippni sivikar kare.
  • @
    @vineet10344 years ago It that same as:
    selectsum(salary) totalsalary
    from employees group by
    right?
  • @
    @LuigiZambetti5 years ago Where i can find the script to create the database used in these examples?
  • @
    @manishdubey86468 years ago Realyall videos are awesome. I have seen all and implement in my project. Very clearly understanding. Also i have shared multiple people who doesn' t know about sql. Multiple friends got a job only credit goes to your videos. ...Expand 1
  • @
    @jcsrmpras9 years ago Hi sir, this is prasanna with the help of your video tutorials. I learned dotnet and sql. They helped me in clearing my interview. Im appointed as a dot . ...Expand 4
  • @
    @JohnWaclawski4 years ago I know this is a fairly old video, but any chance we can get the sample database you were using?
    thank you for all you do. I' ve watched many edit: funny but i watched this video 4 months ago & commented on it then too. Still looking for the sample db you used. ...Expand