group by syntax

The complete syntax of the select statement is repeated here so that you can see the group by clause in context:

select [all | distinct] select_list 
     [into [[database.]owner.]table_name] 
     [from [[database.]owner.]{view_name | table_name
          [(index {index_name | table_name} 
               [parallel [degree_of_parallelism]]
               [prefetch size ] [lru | mru])]}
          [holdlock | noholdlock] [shared]
     [,[[database.]owner.]{view_name | tablel_name
         [(index {index_name | table_name} 
               [parallel [degree_of_parallelism]]
               [prefetch size] [lru | mru])]}
          [holdlock | noholdlock] [shared]]...] 
 
     [where search_conditions] 
 
     [group by [all] aggregate_free_expression
          [, aggregate_free_expression]...]
     [having search_conditions]
 
     [order by 
     {[[[database.]owner.] {table_name. | view_name.}]
          column_name | select_list_number | expression} [asc | desc]
     [, {[[[database.]owner.]{table_name|view_name.}]
          column_name | select_list_number | expression
               [asc | desc]]...]
 
     [compute row_aggregate (column_name)
               [, row_aggregate(column_name)]...
          [by column_name [, column_name]...]] 
     [for {read only | update [of column_name_list]}]
     [at isolation {read uncommitted | read committed | serializable}]
     [for browse]

Remember that the order of the clauses in the select statement is significant. You can omit any of the optional clauses, but when you use them, they must appear in the order shown above.