Pregunta

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?

¿Fue útil?

Solución

My interpretation of your question:

SQL check if numerical value is 0 for a field (Field1) [only] when id is=333
[If id is not 333, don't need to check]

SELECT CASE WHEN isnull(id,0) <> 333 OR Field1=0 THEN 1 ELSE 0 END
      ,other1, other2
  FROM tbl

Otros consejos

select
    case
        when (select column_name from sometable where id = @id) = 0 then
        else 
    end
select 
 case when( select column from table where id=333)=0 then "your condition"
else
end
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top