1.需求
select查询的时候引用之前计算出来的值2.背景信息SELECT AutoID,(Distance-EndGap) as Length,(Length/Distance) as Percentage
FROM `tb_train_schedule`..................
3.我的问题
我执行如上的代码,则提示出错,主要问题是:(Length/Distance) as Percentage
Unknown column 'Length' in 'field list'
虽知可以:SELECT AutoID,(Distance-EndGap) as Length,(Distance-EndGap/Distance) as Percentage
FROM `tb_train_schedule`..................但是当计算表达式很长的时候,阅读起来则不悦目,因此我想知道像我这样的问题是否有好的解决方案?
4.我的代码
略5.帖尾
小生才学疏浅 ,请高手指教 ,临帖涕零,不知所言 , 谢谢 ~ !
select查询的时候引用之前计算出来的值2.背景信息SELECT AutoID,(Distance-EndGap) as Length,(Length/Distance) as Percentage
FROM `tb_train_schedule`..................
3.我的问题
我执行如上的代码,则提示出错,主要问题是:(Length/Distance) as Percentage
Unknown column 'Length' in 'field list'
虽知可以:SELECT AutoID,(Distance-EndGap) as Length,(Distance-EndGap/Distance) as Percentage
FROM `tb_train_schedule`..................但是当计算表达式很长的时候,阅读起来则不悦目,因此我想知道像我这样的问题是否有好的解决方案?
4.我的代码
略5.帖尾
小生才学疏浅 ,请高手指教 ,临帖涕零,不知所言 , 谢谢 ~ !
from (
SELECT AutoID,(Distance-EndGap) as Length
FROM `tb_train_schedule`..................
)T
((Distance-EndGap)/Distance) as Percentage
FROM `tb_train_schedule`..................