我們必須在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也