SQL check if numrical value is 0 for a field where id is=333
-
09-07-2021 - |
Pergunta
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?
Solução
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
Outras dicas
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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow