select case when col is not null then '0' else '1' end from tb
select case when col is null or col = '' then '1' else '0' end from tb
查询条件非空为‘0’,空且不为“无”或“不是”则为‘1’怎么写 select case when col is not null then 0 when col is null and col not in('无','不是') then 1 else col end from tb
select case when col is not null then 0 when col is null and not in('无','不是') then 1 end from tb
空且不为“无”或“不是”则为‘1’既然是空了,就肯定不会是'无','不是'等其他内容.也许楼主说反了. 条件应该是: 非空且不为“无”或“不是”为‘0’,空或者无,不是则为‘1’select case when col is null or col in {'无','不是'} then '0' else 1 end from tb以上这些SQL语句,楼主自己选个合适的吧.
from tb
case when col is not null then 0
when col is null and not in('无','不是') then 1
end
from
tb
条件应该是:
非空且不为“无”或“不是”为‘0’,空或者无,不是则为‘1’select case when col is null or col in {'无','不是'} then '0' else 1 end from tb以上这些SQL语句,楼主自己选个合适的吧.