用DATEDIFF计算

时间:2019-03-07 15:26:29

标签: datediff

谁能解释then 1 else 0 end计算的内容吗?
我不知道declare @months table (value varchar(25)) insert into @months values (1) insert into @months values (2) insert into @months values (3) insert into @months values (4) insert into @months values (5) insert into @months values (6) insert into @months values (7) insert into @months values (8) insert into @months values (9) insert into @months values (10) insert into @months values (11) insert into @months values (12) select mem_no , eff_dt , term_date , datediff(month, EFF_DT, TERM_DATE) - case when datepart(day, EFF_DT) > datepart(day, TERM_DATE) then 1 else 0 end as active2012, m.value as [active_month] from #temp_eligibles, ,@months m where m.value between datepart(m,EFF_DT) and datepart(m,term_date) and EFF_YR = '2012' 在做什么。

UPDATE RH SET
--SELECT RH.economic_class ,
economic_class = C.economic_class
FROM dbo.tblRecHist RH
JOIN tblComp C ON RH.company_id = C.company_id
WHERE RH.company_id = @CompID
AND RH.rec_date = @RecDate

0 个答案:

没有答案