[sql] Using BETWEEN in CASE SQL statement