Can anyone advice what is wrong here?
I got multiple syntax errors.
IF (('05:00' < CAST(t.Scan_In_Prod AS TIME)) AND (CAST(t.Scan_In_Prod AS TIME) < '08:00'))
BEGIN
(CASE WHEN (CAST(t.Scan_In_Prod as TIME) < CAST(t.Scan_Out_Prod AS TIME)) AND (CAST(t.Scan_Out_Prod as TIME) < '19:00')
THEN 'Early Out'
WHEN ('07:00' < CAST(t.Scan_In_Prod AS TIME)) AND (CAST(t.Scan_In_Prod AS TIME) < CAST(t.Scan_In_Prod AS TIME))
THEN 'Late In'
END)
END
Errors are shown below:
Msg 156, Level 15, State 1, Line 25
Incorrect syntax near the keyword 'if'.Msg 156, Level 15, State 1, Line 29
Incorrect syntax near the keyword 'case'.Msg 156, Level 15, State 1, Line 42
Incorrect syntax near the keyword 'case'.Msg 102, Level 15, State 1, Line 107
Incorrect syntax near 't'.
CASEstatement sitting there in isolation with no query. This is the problem.