What is SQL GROUP BY?
The SQL GROUP BY is a clause enables SQL aggregate functions for a grouping of information. For example, it could support subtotaling by region number in a sales table.
How To Use SQL GROUP BY
SQL GROUP BY is used as follows. It must follow the FROM and WHERE clauses. The columns in a SELECT clause must be either group by columns or aggregate function columns.
SQL GROUP BY Syntax
SQL GROUP BY Example
The following example produces a count of branches by region_nbr from the branch table.
Here are the contents of the table:
This SQL Statement with GROUP BY is executed:
Here is the result.
|HOME | SQL OVERVIEW | SQL BASICS | SQL ADMINISTRATION | SQL ADVANCED | SQL SYNTAX|
|Copyright© 1999-2012, First Place Software, Inc.|