'ORDER BY' should come after 'GROUP BY'

otherwise it generate an error like this one: 

{ [Error: syntax error at or near "GROUP"]
  severity: 'ERROR',
  code: '42601',
  position: '558',
  file: 'scan.l',
  line: '1001',
  routine: 'scanner_yyerror' }