我使用Checkin_to_triage
函数计算了时间跨度变量Datediff
,并希望将该变量中的值分类为新变量Pre_Arrival
。我尝试使用下面的代码,但由于使用了invalid column name 'checkin_to_triage'
代码,显然收到了IIf ([checkin_to_triage]<60 And [checkin_to_triage]>0,'PreArrival','Null') AS Pre_Arrival
错误消息,因为Pre_Arrival
变量不是我的数据集中的字段。
use EMTCQIData
DECLARE @StartDate Date
DECLARE @EndDate Date
Set @StartDate = '01/01/2018'
Set @EndDate = '12/31/2018'
SELECT *,
Format([CHECKIN_DATE_TIME],'dddd') AS [Checkin_Day],
Format([CHECKIN_DATE_TIME],'dddd dd/mm/yyyy') AS checkin_day_date,
CONVERT(VARCHAR(20),[CHECKIN_DATE_TIME],108) as Checkin_Time,
DateDiff("n",CHECKIN_DATE_TIME,triage_date_time) AS checkin_to_triage,
IIf ([checkin_to_triage]<60 And [checkin_to_triage]>0,'PreArrival','Null') AS Pre_Arrival
FROM ED_TAT_MASTER
WHERE (CHECKIN_DATE_TIME > @StartDate and CHECKIN_DATE_TIME < @EndDate)