case statement in teradata with where clause