如何获得两列值的百分比 [英] how to get percentage of two column value

查看:107
本文介绍了如何获得两列值的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 cte3_persenta(per) as  
select ((cte1.totalcount / cte2.TotaCount)* 100
其中 cte1.emp = cte2.emp
来自 cte1,cte2)





i am创建一个上面显示的新cte表

来自cte1.totalcount的值'2'和
来自cte2.TotaCount的
值'500'

i想要这些值的百分比它应该是0.00%格式





i想要来自cte3表的每个is = 0.40%



请帮助一个人

解决方案

请这样做..



 选择 cte1totalcount,cte2totalcount,(cte1totalcount / cte2totalcount)* 100  as  cet3 来自 emp_status 


 选择 cte1.totalcount,cte2。 totalcount,(cte1.totalcount / cte2.totalcount)* 100  as  cte3_persent 来自 cte1  join   inner  cte2  on  cte1.emp = cte2.emp 


cte3_persenta (per) as
(select ((cte1.totalcount/cte2.TotaCount)* 100 )
where cte1.emp=cte2.emp
from cte1,cte2)



i am creating one new cte table shown above
from that value '2'coming from cte1.totalcount and
value '500' coming from cte2.TotaCount
i want percentage of those value it should be in 0.00% format


i want ans of per from cte3 table is =0.40%

please help some one

解决方案

Please do this..

select cte1totalcount,cte2totalcount,(cte1totalcount/cte2totalcount)*100 as cet3  from emp_status 


select cte1.totalcount,cte2.totalcount ,(cte1.totalcount/cte2.totalcount)*100 as cte3_persent from cte1 join inner cte2 on cte1.emp=cte2.emp 


这篇关于如何获得两列值的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆