sql 3

Sql代码   收藏代码
  1. select smallRfunctions  from ( SELECT smallRfunctions,count(resDepart) as num FROM paCuAssessment  
  2.  where  datediff(m,subDate,getDate())=0 group by bigRfunctions, smallRfunctions) m  
  3. where m.num >=(SELECT coeffValue  
  4. FROM PaCoefficient  
  5. WHERE (item = '责任部门下限'))  


一个职能大项对应多个小项,一个小项对应多个职能部门,需求:根据职能小巷的职能部门数目分组 
=================================================================================== 

Sql代码   收藏代码
  1. select * from dbo.PAtaskDataEntry where alarmScope is not null and datediff(m,taskDate,getdate())=1 and   
  2.   
  3. convert(numeric(8,2),currentData) < convert(numeric(8,2),substring(alarmScope,0,charindex('-',alarmScope))) or  
  4.   
  5. convert(numeric(8,2),currentData)>  convert(numeric(8,2),substring(alarmScope,charindex('-',alarmScope)+1,len(alarmScope)))  


======================================================================================= 


--创建示例表 
Sql代码   收藏代码
  1. declare @t table (c1 int,c2 int,c3 int,c4 int)  
  2. insert @t select 1,2,3,0  
  3. union all select 1,3,2,0  
  4. union all select 3,1,2,0  


--查询语句 
Sql代码   收藏代码
  1. update @t set c4=(  
  2. case when c1>c2 and c1>c3 then c1  
  3.      when c2>c1 and c2>c3 then c2  
  4.      else c3 end   
  5. )  


==========================================================================================
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值