mysql4 order by不支持函数bug

mysql 4.1.18 中存在不支持函数order by的bug

 

select a, sum(b)
from tablename
group by a
order by sum(b)

 

此时会出现ERROR 1111 (HY000): Invalid use of group function

 

绕过此bug的方法是给sum(b) 加上as

 

select a, sum(b) as ss
from tablename
group by a
order by ss

 

这样就OK了

你可能感兴趣的:(mysql)