Export (0) Print
Expand All
2 out of 8 rated this helpful - Rate this topic

SELECT - SQL Command - GROUP BY Clause

Visual Studio 2005

The GROUP BY clause specifies one or more columns used to group rows returned by the query. Columns referenced in the SQL SELECT statement list, except for aggregate expressions, must be included in the GROUP BY clause. You cannot group by Memo, General, or Blob fields.

For the complete syntax, see SELECT - SQL Command.

The detailed syntax for the GROUP BY clause is as follows:

[GROUP BY Column_List_Item [, ...] ]



Specifies one or more columns used to group rows returned by the query.

Column_List_Item can be one of the following:

  • A field in a table in the FROM clause or a subquery.

  • A table alias from the SQL SELECT list.

  • A numeric expression indicating the location of the column in the result table. The leftmost column is number 1.

The following code shows a summary of the main clauses of the SELECT - SQL Command:

SELECT Select_List
   FROM Table_List
...[WITH (BUFFERING = lExpr)]
   [WHERE Conditions]
   [GROUP BY Column_List]
   [HAVING Conditions]
   [UNION Clause]
   [ORDER BY Column_List]
   [INTO Clause | TO Clause ]

For more information about a particular clause of the SQL SELECT command, see the following topics:

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.