Hi Dirk, from the excellent on-line manual:
http://dev.mysql.com/doc/mysql/en/SELECT.html
Columns selected for output can be referred to in ORDER BY and GROUP BY clauses using column names, column aliases, or column positions. Column positions are integers and begin with 1:
mysql> SELECT college, region, seed FROM tournament -> ORDER BY region, seed; mysql> SELECT college, region AS r, seed AS s FROM tournament -> ORDER BY r, s; mysql> SELECT college, region, seed FROM tournament -> ORDER BY 2, 3;
/Johan
Dirk Bremer (NISC) wrote:
(The count(*) expression is the second column of the result set so you replace it with a 2). This saves you from having to use an 'As' expression for 'count(*)' although it makes the query less clear too. (It won't be apparent to some people what the effect of the '2' in the 'order by' is.)
Rhino
Thanks for all of the suggestions, the 'order by count' worked like a charm. Concerning Rhino's suggestion quoted above, it this method of using numbers to represent the columns documented anywhere?
-- Johan Höök, Pythagoras Engineering Group - MailTo:[EMAIL PROTECTED] - http://www.pythagoras.se Pythagoras AB, Stormbyv. 2-4, SE-163 55 SPÅNGA, Sweden Phone: +46 8 760 00 10 Fax: +46 8 761 22 77
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]