我有一个表包含两种类型的信息,一种叫做Number_Of_Calls
,另一种叫Number_Of_Answered
。
现在,在我的应用程序中,我想知道Number_of_answered
中Number_of_calls
的百分比是多少,我认为在数据库中计算将是最好的方法。
但是我不知道如何在SQL中计算
到目前为止,我有:
Select Number_Of_Calls,
Number_of_answered
from table
Where Date BETWEEN '2012-09-10' AND '2012-09-11'
答案 0 :(得分:6)
select
Number_of_Calls,
Number_of_Answered,
((Number_of_answered/Number_Of_Calls)*100) as answer_percent,
Date
from table Where Date BETWEEN '2012-09-10' AND '2012-09-11'
答案 1 :(得分:3)
select
Number_Of_Calls,
Number_of_answered
((Number_of_answered/Number_Of_Calls)*100.00) as percent
from table_name Where Date BETWEEN '2012-09-10' AND '2012-09-11'