• As other have stated it is not clear exactly what sort of logic you are trying to achieve with just a select statement.

    Having said that though, your case statement is not correctly formed to produce consistent results, and you have an OR in their with no parenthesis to insure proper precedence.

    What it looks like you are trying to do is to compare check in or check out times against a threshold and then set a status code. Instead of an overly complicated case statement it might be cleaner to join against a table that contains the time values your are checking against. This time map table can be a CTE and would result in more readable SQL.

    Converting datetime to nvarchar's then comparing the result to other char strings is not a good way to check time periods across sets of data.

    The probability of survival is inversely proportional to the angle of arrival.