Skip to content
Advertisement

GROUP BY in SQL query is giving syntax error when used with Order By

I have this query:

where 31, 26 are the cus_id of the customers whose last messages I want to fetch.I am getting all the messages sorted asscording to time between the 1 and ( 31,26 ) customer if I remove GROUP BY constraint. But adding it gives me this syntax error

I have disabled ONLY_FULL_GROUP_BY SQL mode. Still I dont know How to fetch the last message.

Advertisement

Answer

This is not an aggregation operations, this is a filtering operations.

Use window functions:

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