select中不能用别的列的别名吗
我想写一个select,其中一个字段是
case aaa
when 1 then a * b / 100
when 2 then a / (100 + b) * b
end
而其中的b是一个有点复杂的子查询,
我想写成
select
(select ccc from ddd where ......) as b,
case aaa
when 1 then a * b / 100
when 2 then a / (100 + b) * b
end
from ...
可是好像编译不过去,我必须写成下面这样吗
select
(select ccc from ddd where ......) as b,
case aaa
when 1 then a * (select ccc from ddd where ......) / 100
when 2 then a / (100 + (select ccc from ddd where ......) ) * (select ccc from ddd where ......)
end
from ...
谢谢了