select t1.mk,t2.gnjy,t1.rjcw,t3.total,count(t1.rjcw)/(t3.total*1.0) percentagefrom (select mk,count(cswhdxs) as rjcw from YSDP_DATA where YEAR(TJSJ)=2015 and CSWHDXS='软件错误' group by mk) t1 left join (select mk,count(cswhdxs) as gnjy from YSDP_DATA where YEAR(TJSJ)=2015 and CSWHDXS='功能建议' group by mk) t2 on t1.mk=t2.mk left join (SELECT mk,count(cswhdxs) AS total FROM YSDP_DATA where year(TJSJ)=2015 group by MK) t3 on t1.mk=t3.mkgroup by t1.MK,t1.rjcw,t2.gnjy ,t3.total 查询语句如上,目的很简单,就是统计表中字段CSWHDXS中(特定年份)软件错误 和 功能建议 的数量并算出 软件错误 在该列的占比,最后用另一字段mk进行分类。现在前4列应该都没有问题,最后一列计算却有明显错误,结果如下图最后一列明显计算错误,求教大家原因在哪里,应该如何修改。或者是我的思路根本不对。
1 回答
月关宝盒
TA贡献1772条经验 获得超5个赞
count(t1.rjcw)/(t3.total*1.0) percentage
改成
t1.rjcw/(t3.total*1.0) percentage
- 1 回答
- 0 关注
- 696 浏览
添加回答
举报
0/150
提交
取消