All Forums Database
Akash 1 post Joined 02/10
11 Feb 2010
Where Clause with CASE WHEN THEN END statement.

Hi,I am trying to put the Case statement in Where clause but DB gives me error:-3706. Syntax Error : expected something between ')' and the 'between' keyword.Is Teradata supports the Where clause with Case statement.Query like:-Select Start_time_id,datetimefromDatetime_TableWhere Case When 'Previous Day' then ((Start_time_id) between 12345 And 123459)When 'Previous Week' then ((Start_time_id) between 23456 And 234459)ENDPlease suggest me..Or explain me with some example.Regards,Akash

Thiru 15 posts Joined 10/08
12 Feb 2010

Hi,Against which column you want to quantify or what is the exact requirement?

Jim Chapman 449 posts Joined 09/04
12 Feb 2010

In a CASE expresssion, THEN must be followed by a scalar value expression. The entire CASE expression evaluates to a scalar value, not a predicate. You can use CASE in a WHERE clause, but the outer expression must be used in a predicate, as in the following example:SELECT * FROM tWHERE x = CASE WHEN y=2 THEN 1 ELSE 2 END;

You must sign in to leave a comment.