oracle字段相除保留两位小数,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=2spa
显示结果为 co
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
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)