SQL Server - Grouping Set

Published: 21 February 2021
on channel: PracticalIT
203
2

Introduction

We all know the use of a "group by" statement. Normally a GROUP BY statement is used in conjunction with aggregate functions (like sum, count, avg etc.) to group the result-set by one or more columns. In a sort, whenever data is to be summarized, the developer uses a Group By clause. The GROUP BY clause is also used to get DISTINCT rows from any result set.

GROUPING SET is introduced in SQL Server 2008. GROUPING SET is able to generate a result set that can be generated by a UNION ALL of multiple simple GROUP BY clauses. It is capable of generating a result set that is equivalent to the result set generated by ROLL UP or CUBE operations.

GROUPING SETS Equivalents

Specifying GROUPING SETS as the GROUP BY list is equivalent to a UNION ALL of queries, each with one of the grouping sets as its GROUP BY list. We can also use GROUPING SETS in replacement of ROLLUP and CUBE.

#practicalit #sqltutorial #groupingsetinsqlserver


On this page of the site you can watch the video online SQL Server - Grouping Set with a duration of hours minute second in good quality, which was uploaded by the user PracticalIT 21 February 2021, share the link with friends and acquaintances, this video has already been watched 203 times on youtube and it was liked by 2 viewers. Enjoy your viewing!