这是我写的查询语句
select
b.dept_name,
count(a.CNS_INS_ID) as xinxiyuan,
c.bianji,
count(case when a.CNS_DIAL_NUMBER > 0 then '已拨打' end) as yiwancheng,
count(case when a.CNS_DIAL_NUMBER is NULL then '未拨打' end) as weiwancheng
from LZ_COUNT_SOURCES_yue a
left join lz_department b on a.dept_id =b.dept_id
left join
(
select count(admin_id ) as bianji,dept_id from lz_admin
group by dept_id
) c on b.dept_id = c.dept_id
where a.parent_id = 60
group by b.dept_name,c.bianji
怎么算出yiwancheng除以xinxiyuan的百分比
用sql怎么计算完成率百分号
答案:2 悬赏:70
解决时间 2021-04-22 02:18
- 提问者网友:✐ۖ﹏ℳ๓北风
- 2021-04-21 22:04
最佳答案
- 二级知识专家网友:啵啵桃汀
- 2021-04-21 22:38
select *,cast(round((yiwancheng/xinxiyuan),2)*100 as varchar(20))+'%' as baifenbi from (
select
b.dept_name,
count(a.CNS_INS_ID) as xinxiyuan,
c.bianji,
count(case when a.CNS_DIAL_NUMBER > 0 then '已拨打' end) as yiwancheng,
count(case when a.CNS_DIAL_NUMBER is NULL then '未拨打' end) as weiwancheng
from LZ_COUNT_SOURCES_yue a
left join lz_department b on a.dept_id =b.dept_id
left join
(
select count(admin_id ) as bianji,dept_id from lz_admin
group by dept_id
) c on b.dept_id = c.dept_id
where a.parent_id = 60
group by b.dept_name,c.bianji) as temp
select
b.dept_name,
count(a.CNS_INS_ID) as xinxiyuan,
c.bianji,
count(case when a.CNS_DIAL_NUMBER > 0 then '已拨打' end) as yiwancheng,
count(case when a.CNS_DIAL_NUMBER is NULL then '未拨打' end) as weiwancheng
from LZ_COUNT_SOURCES_yue a
left join lz_department b on a.dept_id =b.dept_id
left join
(
select count(admin_id ) as bianji,dept_id from lz_admin
group by dept_id
) c on b.dept_id = c.dept_id
where a.parent_id = 60
group by b.dept_name,c.bianji) as temp
全部回答
- 1楼网友:许你一世温柔
- 2021-04-21 23:05
select cast( cast ( ( select count(1) as jige from 表 where 课程名称 = 'c语言' and 分数 >= 60 ) as numeric(10,4) ) / cast ( ( select count(1) as jige from 表 where 课程名称 = 'c语言' ) as numeric(10,4) ) * 100 as varchar(20) ) + '%'
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯