Teradata日期差异

时间:2015-11-23 08:11:59

标签: function teradata period

您好我使用以下查询来查找日期差异,但我在源和目标之间得到一小时的差异,但是当我手动检查excel值中的日期时是匹配的。

select  a.CASE_ID as CASE_ID,a.FST_QUE_TIME_IN_SECStest   as        
FST_QUE_TIME_IN_SECS from  (select 
distinct CC.CASE_ID as CASE_ID,
CC.CASE_STS_CD,
CC.CRT_DTTM_PST,
CC.REC_DTTM_PST,
MIN(case when CC.CASE_STS_CD ='Open' then CC.CRT_DTTM_PST  end )as  
FST_QUE_TIME_IN_SECS1,
MIN(case when CC.CASE_STS_CD ='Open' then CC.REC_DTTM_PST end ) as  
FST_QUE_TIME_IN_SECS2,
(FST_QUE_TIME_IN_SECS1-FST_QUE_TIME_IN_SECS2 DAY(4) to SECOND) as  
FST_QUE_TIME_IN_SECS,
cast(extract (day from FST_QUE_TIME_IN_SECS) * 86400 +  extract(hour from    
FST_QUE_TIME_IN_SECS) * 3600 +   extract(minute from   
FST_QUE_TIME_IN_SECS)    
*60 +   extract(second from FST_QUE_TIME_IN_SECS) as INTEGER)as   
FST_QUE_TIME_IN_SECStest 

FROM EDW_KATAMARI_T.CNTCT_CASE   CC 
where CC.CASE_ID='14424461'
group by 1,2,3,4
)
a
where a.FST_QUE_TIME_IN_SECStest is not NULL 

minus

select 
CASE_ID, 
FST_QUE_TIME_IN_SECS

from EDW_KATAMARI_T.CNTCT_CASE_SUMRY 
where  CASE_ID='14424461'

0 个答案:

没有答案