Skip to content
Advertisement

Group or Aggregate functions (min(),max(),sum(),count(),…etc.,) cannot be used within the Group by/Order by/Where/ON clause

It seems that I can not order by the count of a column which is odd because I have seen plenty of examples where the count() is used in the ORDER BY statement. I am using Zoho Analytics. Here is my query:

Advertisement

Answer

Try using an alias:

Most databases support arbitrary expressions in the ORDER BY. However, some require that the sorting expression actually be a column — and they don’t detect when a SELECT expression is the same as the ORDER BY expression. I’ve hit this problem before (I think with Hive) and just thought this might work in your environment.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement