Previous |
Next
What is SQL GROUP BY?The SQL GROUP BY clause enables aggregate functions for a grouping of information. For example, it could support subtotaling by region number in a sales table. Why Use SQL GROUP BY?The SQL GROUP BY clause is used whenever aggregate functions by group are required. This is an aid to understanding and analyzing information. How To Use SQL GROUP BYSQL 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:
Table: BRANCH
This SQL Statement with GROUP BY is executed:
Here is the result.
|
SQL OVERVIEW
SQL BASICS
SQL SELECT
SQL WHERE
SQL INSERT
SQL UPDATE
SQL DELETE
SQL ADMINISTRATION
SQL CREATE DATABASE
SQL DROP DATABASE
SQL CREATE TABLE
SQL ALTER TABLE
SQL DROP TABLE
SQL CREATE INDEX
SQL DROP INDEX
SQL ADD FOREIGN KEY
SQL DROP FOREIGN KEY
SQL CREATE VIEW
SQL DROP VIEW
SQL ADVANCED
SQL CONCAT
SQL SUBSTRING
SQL TRIM
SQL AND & OR
SQL IN
SQL BETWEEN
SQL LIKE
SQL DISTINCT
SQL GROUP BY
SQL AGGREGATE
SQL HAVING
SQL ORDER BY
SQL JOIN
SQL OUTER JOIN
SQL SYNTAX
| HOME | SQL OVERVIEW | SQL BASICS | SQL ADMINISTRATION | SQL ADVANCED | SQL SYNTAX |
| Copyright© 1999-2006, First Place Software, Inc. |






