我们必须在SQL Server表6列SLA 我试图从下面的添加compained列QASLA 创建 - 实心柱有日期时间 - 非NULLNULL日期计算的SQL Server
EsculationDate - [EsculationFeedback] [InternalEsculationReplay ] - [InternalEsculationDate]列是 时间类型,当我尝试插入一个新的记录可能为NULL值
alter table SLA
add QASLA as
iif((Closed=null),datediff(dd,getdate(),Created),
(datediff(dd,Closed,Created))-datediff(dd,IIF(COALESCE ([EsculationDate],0)>COALESCE ([InternalEsculationDate],0),COALESCE ([InternalEsculationDate],0),COALESCE ([EsculationDate],0)),
IIF(COALESCE ([EsculationFeedback],0)>COALESCE ([InternalEsculationReplay],0),COALESCE ([EsculationFeedback],0),COALESCE ([InternalEsculationReplay],0))))
insert into [dbo].[SLA]
([Created],[EsculationDate],[EsculationFeedback],[Closed])
values('10-Jun-15','10-Jun-15','15-Jun-15','15-Jun-15')
QASLA结果= -42173 我需要0值作为创建日期= 6月10日和结束日期= 6月15日分钟(EsculationDate + EsculationFeedback) 我尝试使用ISNULL也