0

我寻求一种能够写出这样的东西的方法

select complicated_calculation1 as comp1, 
complicated_calculation2 as comp2, 
(comp1/comp2) as percent
from table

而不是像这样以更复杂的方式编写它

select complicated_calculation1 as comp1, 
complicated_calculation2 as comp2, 
(complicated_calculation1/complicated_calculation2) as percent
from table

这可能吗?

4

2 回答 2

0

不在同一行。

你可以做的是:

SELECT comp1, comp2, (comp1/comp2) as percent FROM(
select complicated_calculation1 as comp1, 
complicated_calculation2 as comp2
from table) AS t
于 2013-02-01T09:16:36.180 回答
0
no u cann't use this 

select complicated_calculation1 as comp1, 
complicated_calculation2 as comp2, 
(comp1/comp2) as percent
from table

u have to use only this 

select complicated_calculation1 as comp1, 
complicated_calculation2 as comp2, 
(complicated_calculation1/complicated_calculation2) as percent
from table

because rantime calculation can not be applied on Alis field name
于 2013-02-01T09:22:05.357 回答