oracle数据库显示两个字段相除的结果分析

select sum(a.pf_value) totalrating ,count(zy_id) countrating from mic_td_user_pf a  

where a.zy_id=199 and a.pf_type=2

显示结果为 

totalrating countrating 

26       7

select b.countrating ,b.totalrating/b.countrating avgrating from (select sum(a.pf_value) totalrating ,count(zy_id) countrating from mic_td_user_pf a  

where a.zy_id=199 and a.pf_type=2) b 

countrating avgrating 

7          3.71428571428571

保留4位小数

select b.countrating ,round(b.totalrating/b.countrating,4) avgrating  

from (select sum(a.pf_value) totalrating ,count(zy_id) countrating  

from mic_td_user_pf a  where a.zy_id=199 and a.pf_type=2 and a.del_mark = 0) b ;

countrating avgrating 

7          3.7143

(0)
上一篇 2022年3月22日
下一篇 2022年3月22日

相关推荐