From the course: Querying Microsoft SQL Server 2019
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Understand record grouping - SQL Server Tutorial
From the course: Querying Microsoft SQL Server 2019
Understand record grouping
- [Instructor] The queries that we've explored so far have all returned a number of rows from the database. We can start to group those rows together based off of common attributes, in order to get summary details and other useful kinds of information from the database. My favorite way of thinking about grouping records in a query is to imagine a standard deck of 56 playing cards. Each card in the deck will represent one row in the query result. You can then take that deck of cards and separate them out by color, make one pile for black cards, and another for red. You've just created two groups from the original deck of cards, based off of their color. Or, you could group the cards into four groups, one for each suit. That would give you a pile of club cards, spades, hearts, and diamond cards. Or you could group the cards based off of their value. That would leave you with 13 groups with four cards each, four aces…