SELECT Statement SELECT college, region AS r, seed AS s FROM tournament ORDER BY r, s; SELECT college, region, seed FROM tournament ORDER BY 2, 3; To sort in reverse order, add the  DESC  (descending) keyword to the name of the column in the  ORDER BY  clause that you are sorting by. The default is ascending order; this can be specified explicitly using the  ASC  keyword. If  ORDER BY  occurs within a parenthesized query expression and also is applied in the outer query, the results are undefined and may change in a future version of MySQL. Use of column positions is deprecated because the syntax has been removed from the SQL standard. As of MySQL 8.0.13, the  GROUP BY  extension is no longer supported:  ASC  or  DESC  designators for GROUP BY  columns are not permitted.  Previously, it was not permitted to use  ORDER BY  in a query having a  WITH ROLLUP  modifier. This restriction is lifted as of MySQL 8.0.12. See Section 12.20.2, “GROUP BY Modifiers” . The  HAVING  clause is applied nearly last, just before items are sent to the client, with no optimization. ( LIMIT  is applied after  HAVING .) The SQL standard requires that  HAVING  must reference only columns in the  GROUP BY  clause or columns used in aggregate functions. However, MySQL supports an extension to this behavior, and permits  HAVING  to refer to columns in the  SELECT  list and columns in outer subqueries as well. If the  HAVING  clause refers to a column that is ambiguous, a warning occurs. In the following statement, col2  is ambiguous because it is used as both an alias and a column name: Preference is given to standard SQL behavior, so if a  HAVING  column name is used both in  GROUP BY and as an aliased column in the select column list, preference is given to the column in the  GROUP BY column. 2664 SELECT COUNT(col1) AS col2 FROM t GROUP BY col2 HAVING col2 = 2; •The  HAVING  clause, like the  WHERE  clause, specifies selection conditions. The  WHERE  clause specifies conditions on columns in the select list, but cannot refer to aggregate functions. The  HAVING  clause specifies conditions on groups, typically formed by the  GROUP BY  clause. The query result includes only groups satisfying the  HAVING  conditions. (If no  GROUP BY  is present, all rows implicitly form a single aggregate group.) • GROUP BY  permits a  WITH ROLLUP  modifier. See Section 12.20.2, “GROUP BY Modifiers” . •MySQL extends the use of  GROUP BY  to permit selecting fields that are not mentioned in the  GROUP BY clause. If you are not getting the results that you expect from your query, please read the description of GROUP BY  found in Section 12.20, “Aggregate Functions” . • When you use  ORDER BY  or  GROUP BY  to sort a column in a  SELECT , the server sorts values using only the initial number of bytes indicated by the  max_sort_length  system variable. • Prior to MySQL 8.0.13, MySQL supported a nonstandard syntax extension that permitted explicit  ASC or  DESC  designators for  GROUP BY  columns. MySQL 8.0.12 and later supports  ORDER BY  with grouping functions so that use of this extension is no longer necessary. (Bug #86312, Bug #26073525) This also means you can sort on an arbitrary column or columns when using  GROUP BY , like this: SELECT a, b, COUNT(c) AS t FROM test_table GROUP BY a,b ORDER BY a,t DESC;