SQL – Using GROUP BY with ORDER BY
GROUP BY groups rows based on one or more columns. ORDER BY sorts rows. You can use these together to sort groups. There are two options you can use for sorting groups: I’ll show examples below. At the end, I’ll talk about how SQL Server may implicitly sort groups (and why you shouldn’t depend on … Read more