Tell Me
 

Creating Groups: Part 2

Previous previous|next Next Page

You place the GROUP BY clause between the WHERE and ORDER BY clauses in a SQL statement. You specify the GROUP BY keyword followed by a column name or expression that indicates how you want to group the rows.

  • The SELECT clause can contain only the column or columns that appear in the GROUP BY clause, in addition to any group function or functions.
  • The GROUP BY clause must contain any column or columns that appear in the SELECT clause that are not listed in the group function.
  • By default, rows are sorted in ascending order of the columns that are included in the GROUP BY list.
  • The ORDER BY clause is optional. If used, it overrides the default sorting.