【发布时间】:2015-09-28 13:27:37
【问题描述】:
我们在 SQL Server 表 SLA 中有 6 列 我尝试从下面添加组合列 QASLA Created - Closed Columns are datetime - Not NULL
EsculationDate - [EsculationFeedback] [InternalEsculationReplay] - [InternalEsculationDate] 列是 datetime 类型和可能为 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 作为创建日期 = 10 Jun 和 Closed Date = 15 Jun mins (EsculationDate+EsculationFeedback) 我也尝试使用 ISNULL
【问题讨论】:
标签: sql sql-server