In this blog post, you’ll learn more about the Sybase Error Illegal ORDER BY in aggregate function and the reason for receiving this error
Sybase SQL Error Message
Illegal ORDER BY in aggregate function
Reason for this Error
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.