汇总求和,求帮忙

catcatst01 2013-09-25 10:05:13




select agent,
case when qq is null then 0 else 16.67 end q1,
case when email is null then 0 else 16.67 end e1,
case when addr is null then 0 else 16.67 end a1,
case when birthdate is null then 0 else 16.67 end b1,
case when childname is null then 0 else 16.67 end c1,
case when buydate is null then 0 else 16.67 end y1

from emc_srv_card



我要做资料完整度计算,如图,信息录入为空的字段为0,不为空为16.67
我要的结果如下:
agent 资料完整度
liwei 95.12%
李威 96.12%
admin 98.12%



==================各位请帮帮忙,我一共才27分了。
...全文
93 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
catcatst01 2013-09-25
  • 打赏
  • 举报
回复
引用 6 楼 fredrickhu 的回复:
[quote=引用 5 楼 catcatst01 的回复:] 算出来了。
晕 还没看懂 看看你怎么解决的[/quote] select agent,cast(Convert(decimal(18,2),avg(y1)) as varchar(10))+'%' as avg1 from( select agent,(case when (qq is null or qq='') then 0 else 16.667 end + case when email is null or email='' then 0 else 16.667 end + case when addr is null or addr='' then 0 else 16.667 end + case when birthdate is null or birthdate='' then 0 else 16.667 end + case when childname is null or childname='' then 0 else 16.667 end + case when buydate is null or buydate='' then 0 else 16.667 end )y1 from emc_srv_card) t group by agent
--小F-- 2013-09-25
  • 打赏
  • 举报
回复
引用 5 楼 catcatst01 的回复:
算出来了。
晕 还没看懂 看看你怎么解决的
catcatst01 2013-09-25
  • 打赏
  • 举报
回复
算出来了。
catcatst01 2013-09-25
  • 打赏
  • 举报
回复
引用 3 楼 Imaor 的回复:
这三个数据怎么计算出来的? 只有计算结果,没有计算过程? liwei 95.12% 李威 96.12% admin 98.12%
我想要的效果是这样的,不知道怎么计算。 录入数据的平均完整度。
IEEE_China 2013-09-25
  • 打赏
  • 举报
回复
这三个数据怎么计算出来的? 只有计算结果,没有计算过程? liwei 95.12% 李威 96.12% admin 98.12%
catcatst01 2013-09-25
  • 打赏
  • 举报
回复
引用 1 楼 fredrickhu 的回复:
都没看懂是怎么计算来的。
6个字段 每个字段占16.67%
--小F-- 2013-09-25
  • 打赏
  • 举报
回复
都没看懂是怎么计算来的。

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧