Вопрос

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?

Это было полезно?

Решение

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

Другие советы

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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top