Groups are what make aggregate queries even more useful and readable for users. This is why groups are used heavily in reporting. For statistical purposes, groups help to calculate aggregations across sections in data to divide the data in accordance with its meaning. Let's go straight to an example. We have a database called AdventureWorks. This database contains three tables in the Production schema: ProductCategory, ProductSubcategory, and Product. Products are assigned to subcategories, and subcategories are then assigned to categories, so the three tables form a simple hierarchy together. To explore the tables, execute the following query:
SELECT c.ProductCategoryID , c.Name AS CategoryName , psc.ProductSubcategoryID , psc.Name ...