Does it matter which comes after which? I mean if I do
SELECT * FROM table GROUP BY x ORDER BY y
will the results first be grouped and then ordered?
Does it matter which comes after which? I mean if I do
SELECT * FROM table GROUP BY x ORDER BY y
will the results first be grouped and then ordered?
ORDER is the last clause to be executed.
The order of execution
WHERE conditionGROUP BYORDER BYExample :
SELECT * FROM table GROUP BY columnanme ORDER BY columnanmae
In MySQL, a GROUP BY clause has the side effect of sorting columns as well. If you already have a GROUP BY clause in your query that produces the desired sort order, there's no need for an ORDER BY.