2

我想获得count1 / count2
的比率, 这使我符合百分比。这就在我的指尖下方……
我能得到一些帮助吗?

Select 
 (
 Select Count (*) from tso_skf_nomeas_in60days_v 
 ) as count1, 
 (
 Select Count (*) from tso_skf_recent_meas
 ) as count2
 (
 from dual
4

3 回答 3

5

你非常接近:

Select 
    (Select Count (*) from tso_skf_nomeas_in60days_v) 
    / 
    (Select Count (*) from tso_skf_recent_meas) as perc
from dual

SQL 小提琴演示

于 2013-03-14T22:25:04.750 回答
2
SELECT
(SELECT cast(COUNT(*) as float) FROM tso_skf_nomeas_in60days_v)
/
(SELECT cast(COUNT(*) as float) FROM tso_skf_recent_meas) as perc
FROM dual
于 2013-03-14T22:23:53.593 回答
1

更新答案:

Select Count1/Count2
FROM (Select Count(*) Count1 From tso_skf_nomeas_in60days_v) tso_skf_nomeas_in60days_v,
(Select Count(*) Count2 From tso_skf_recent_meas) tso_skf_recent_meas;

如在SQL Fiddle 上所见。

最终结果:

在此处输入图像描述

于 2013-03-14T22:57:02.137 回答