0

I calculated a time span variable Checkin_to_triage using the Datediff function and would like to categorize that values from that variable into new variable, Pre_Arrival. I've tried using the code below but am obviously getting a invalid column name 'checkin_to_triage' error message due to the IIf ([checkin_to_triage]<60 And [checkin_to_triage]>0,'PreArrival','Null') AS Pre_Arrival code, as the Pre_Arrival variable is not a field within my dataset.

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) 
Dale K
  • 25,246
  • 15
  • 42
  • 71
Raven
  • 849
  • 6
  • 17

0 Answers0