+ -
当前位置:首页 → 问答吧 → (1-abs(sign(加班类别-1)))*结果 这是什么意思 ,

(1-abs(sign(加班类别-1)))*结果 这是什么意思 ,

时间:2011-11-30

来源:互联网

select  
(select dept_id from a01 where a01.a0188=a.a0188) as 'dept_id',  
gz_ym,  
a0188,  
sum(abs(1-abs(sign(加班类别-1)))*结果) as '节假日加班',  
sum(abs(1-abs(sign(加班类别-2)))*结果) as '加班'  
from  
(SELECT  
  a0188 as'a0188',  
  convert(varchar(8),start_date,112) as'gz_ym',  
  (case replace(over_class,' ','')  
  when '节假日加班' then 1  
  when '加班' then 2  
  end) as'加班类别',  
  (case replace(result,' ','')  
  when '正常' then 1  
  else 0  
  end) as'结果'  
 from skkq_sk.ldmiskq_sk.dbo.k_OVERTIMEFACT) a  
group by gz_ym,a0188 ) b on a.a0188=b.a0188 and a.dept_id=b.dept_id and a.gz_ym=b.gz_ym  
order by a.gz_ym,a.dept_id,a.a0188  


(1-abs(sign(加班类别-1)))*结果 这是什么意思 ,

作者: ahhfql   发布时间: 2011-11-30

abs去绝对值
sigh取正负性

作者: ssp2009   发布时间: 2011-11-30

SQL code
           
 
SIGN (SSIS)  发送反馈 
  请参阅    
 全部折叠全部展开 语言筛选器: 全部语言筛选器: 多个语言筛选器: Visual Basic语言筛选器: C#语言筛选器: C++语言筛选器: J#语言筛选器: JScript 
函数 (SSIS) >  
 Visual Basic(声明) 
 C#
 C++
 J#
 JScript

返回数值表达式的符号:正号 (+1)、负号 (-1) 或零 (0)。

语法
 
SIGN(numeric_expression)
 

参数
numeric_expression 
是一个有效的有符号数值表达式。有关详细信息,请参阅 Integration Services 数据类型。

结果类型
DT_I4

注释
如果该参数为空,SIGN 返回的结果为空。

示例
此示例返回数值的符号。返回结果为 -1。

 复制代码 
SIGN(-123.45)
 

此示例返回从 DealerPrice 列减去 StandardCost 列的结果的符号。

 复制代码 
SIGN(DealerPrice - StandardCost)
 

请参阅
其他资源
函数 (SSIS)


 

作者: fredrickhu   发布时间: 2011-11-30

作者: codeingman   发布时间: 2011-11-30

拐着弯儿告诉你,节假日加班才算节假日加班 相当于 case 加班类别 when 1 then 1 else 0

个人意见

作者: xiliangxiliangxilian   发布时间: 2011-11-30

不知道是不是函数和case效率不同

作者: xiliangxiliangxilian   发布时间: 2011-11-30