A
A
Alexey Nikolaev2018-02-11 14:11:08
MySQL
Alexey Nikolaev, 2018-02-11 14:11:08

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

1 answer(s)
R
Rsa97, 2018-02-11
@Rsa97

Have you checked what error MySQL gives when doing this.
MySQL syntax only allows ORDER BY after GROUP BY.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question