• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 46. Aggregates > Grouping Results

Grouping Results

Thus far, we have reviewed the basic use of aggregate functions, applying them to entire tables. Aggregate functions can also be used to perform analysis on groups of data. For example, instead of counting all the employees in a company, a function can count them by department. Or instead of returning the highest priced item in a table, a function can return the highest priced item in each category. This type of calculation involves grouping, or specifying how data is to be grouped). When grouped, the aggregate functions return multiple rows—one per group.

You accomplish grouping by using the GROUP BY keyword. GROUP BY takes one or more columns to be grouped (comma delimited if more than one is specified)—columns that must be specified in the SELECT list.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint