select avg(a) as bb from 表名 where bb > 10
这里的别名bb是不能用的
因为sql的执行顺序是from>where>select
所以select中起的别名 where是不能用的
解决办法:
1)select avg(a) from 表名 where avg(a) > 10
2)select cc.bb from (select avg(a) as bb from 表名) cc where cc.bb > 10
sql where 条件判断不能使用select中的别名
于 2021-09-10 15:03:54 首次发布