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.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.041 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.