Bug #11514 Using alias names in ORDER BY expressions does not work
Submitted: 22 Jun 2005 16:54 Modified: 22 Jun 2005 17:02
Reporter: Kai Ruhnau Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.12 OS:Linux (Gentoo Linux)
Assigned to: CPU Architecture:Any

[22 Jun 2005 16:54] Kai Ruhnau
Description:
MySQL does not like alias names in an ORDER BY expression. So,

SELECT a, a AS b
FROM my_table
ORDER BY a,b

works, but

How to repeat:

SELECT a, a AS b
FROM my_table
ORDER BY a+b

or

SELECT a AS b
FROM my_table
ORDER BY ABS(b)

do not

ERROR 1054 (42S22): Unknown column 'b' in 'order clause'

Suggested fix:
One should be able to use aliases anywhere in an ORDER BY.
[22 Jun 2005 17:02] Kai Ruhnau
http://bugs.mysql.com/bug.php?id=1743

Sorry, but searching for "ORDER ALIAS" and similar did not show this.
"Find similar bugs" did.