In an SQL database, a Group By clause can be used in a Select statement to collect data across multiple records and group the results into one or more columns.
According to the Microsoft Developer Network, the “Group By clause groups a selected set of rows into a set of summary rows by the values of one or more columns or expressions in SQL Server 2014.” The discussion goes on to mention that just one row is returned for each group, and aggregate functions in the Select clause <select> list provide information by group instead of by individual rows.
The Group By clause was developed with both an ISO-compliant syntax and a non-ISO-compliant syntax, however, only one syntax can be used for a given Select statement. The non-ISO compliant syntax is available for backward compatibility. Always use ISO compliant syntax for new work.
A Group By clause can be general or simple:
A general Group By clause includes Grouping Sets, Cube, Rollup, With Cube, or With Rollup.
A simple Group By clause does not include Grouping Sets, Cube, Rollup, With Cube, or With Rollup. Group By (), grand total, is usually defined as a simple Group By.
Idera’s SQL Diagnostic Manager database management solution offers a more prosaic, but extremely useful Group By function. The Group By feature in SQL DM makes it possible for you to group the information shown in your views. In order to group information by a column, check the Group By Box option, and then just drag column headings into the space provided.