SQL check if numrical value is 0 for a field where id is=333

user1570048 picture user1570048 · Oct 19, 2012 · Viewed 14.1k times · Source

inside an SQL SELECT CASE STATEMENT how would i check if the a value for some coulmn in sometable is equal to 0 where the id is equal to something?

Answer

Roman Pekar picture Roman Pekar · Oct 19, 2012
select
    case
        when (select column_name from sometable where id = @id) = 0 then
        else 
    end