Groupfieldlist


This clause specifies how to group the returned data. It takes precedence over the ORDER BY clause so that data returns orded by grouping and, within grouping by the orderclause.

Syntax:

 [table.|alias.]field1[, [table.|alias.]field2[, ...]]

NOTE: An error will occur if you do not list the grouped fields in the order in which they appear in the initial fieldlist.

 SELECT field1, field2, field3
 FROM MyTable
 GROUP BY field2, field1

and

 SELECT field1, field2, field3
 FROM MyTable
 GROUP BY field1, field3

will both produce errors.

[Return to SQL Syntax]