Answer the question
In order to leave comments, you need to log in
Why different results if I swap ORDER and GROUP?
Good day.
I have a simple query where I put ORDER BY before GROUP BY. As a result, I always get an empty set. If you change, and do first GROUP BY, and then ORDER, the results are as it should be. Why? Doesn't MySQL have a well-defined plan for executing such expressions?
Bewley read from Alan that GROUP is executed after WHERE. In this case, the ORDER position should not interfere with this order in any way, but the effect is very noticeable nonetheless.
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question