Sometimes when you do GROUP BY, the order of the columns does matter. For example, these two SELECT queries produce different results:
Their actual execution plans are wildly different:
Click through to learn when the ordering in a GROUP BY
clause matters and when it doesn’t.