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 answers

how 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

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -