Skip to content
Advertisement

Cannot use Count(*) in Lag()

I have a simple query but it keeps throwing “Invalid use of group function”. It works fine when I remove “count(*)”. How can I get the count without using it in lag?

Advertisement

Answer

Hmmm . . . MySQL should allow the use of aggregation functions with window functions. Maybe there is a bug in the parser though.

I think this will work:

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