当前位置: 移动技术网 > IT编程>数据库>Oracle > oracle数据库显示两个字段相除的结果分析

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

2018年09月13日  | 移动技术网IT编程  | 我要评论

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网