Illegal ORDER BY in aggregate function
|ODBC 2 State
|ODBC 3 State
|Sybase error code
An ORDER BY can be used in an aggregate function only if there are no DISTINCT aggregates in the select list, or there is
a single DISTINCT aggregate with the DISTINCT column equal to the first column of the ORDER BY. Also, multiple ordered aggregates
cannot be used in the same select list unless they have the exact same ORDER BY clause.