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
如对本文有疑问, 点击进行留言回复!!
Navicate 如何导出数据库中的存储过程、事件、视图等?
每日一记:Oracle升级2020年4月份的数据库补丁Database Patch Set Update : 11.2.0.4.200414 (30670774)
Oracle 19.3 dataguard for Redhat 7.6
网友评论