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

Oracle 21NN 3个月前 (05-23) 11次浏览 未收录 扫描二维码

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


21NN.CN , 版权所有丨如未注明 , 均为原创丨转载请注明原文链接:oracle数据库显示两个字段相除的结果分析-Oracle
喜欢 (0)
[1353713598@qq.com]
分享 (0)
关于作者: