为了账号安全,请及时绑定邮箱和手机立即绑定

SqlServer如何用Sql语句自定义聚合函数 ?

SqlServer如何用Sql语句自定义聚合函数 ?

心有法竹 2019-01-29 10:06:52
我只要聚合函数,表值函数和标量函数就不要冒充了我只要Sql语句创建聚合函数C#的 绕道
查看完整描述

2 回答

?
梵蒂冈之花

TA贡献1900条经验 获得超5个赞

有两个写法:   

select * from tblDept
where id in(select DeptID from tblSalary group by DeptID having  
count(case when Salary>3000 then 1 else null end)*1.0/count(*)>0.5)

select * from tblDept
where id in(select DeptID from tblSalary group by DeptID having  
sum(case when Salary>3000 then 1 else 0 end)*1.0/count(*)>0.5)



查看完整回答
反对 回复 2019-03-16
  • 2 回答
  • 0 关注
  • 1230 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信