CASE statement with IN clause in SQL SERVER -
CASE statement with IN clause in SQL SERVER -
this question has reply here:
using case statement within in clause 4 answershow can utilize case statement in status along in clause? trying next query , giving syntax error.
select * tblcustomers custcode = 'cst1' , case @accounttype when 'doemstic' city in ('hokkaido','tokyo') else city in ('mumbai') end
this statement gives syntax error near 'in'
i using sql server 2012
when have similar, seek write in way:
select * tblcustomers custcode = 'cst1' , ( ( @accounttype = 'doemstic' , city in ('hokkaido','tokyo') ) or ( @accounttype <> 'doemstic' , city in ('mumbai') ) )
if has improve idea, please share
sql-server case
Comments
Post a Comment