>我有一个表"Cabine",其中包含字段"SBC750"(整数)和"Evaso"(tinyint)
字段 Evaso 可以是 1、0 或 Null
我正在寻找所有 sbc750 的总和,其中 Evaso 不是 1。
我试过
select sum(sbc750) from cabine where evaso<>1;
但结果为空:为什么???
如果我使用
select sum(sbc750) from cabine
我得到55,如果我使用
select sum(sbc750) from cabine where evaso=1
我得到34!
因此,结果可能是 21 而不是 Null。请帮助我
使用 NULL-safe
相等运算符,您应该得到所需的结果:
select sum(sbc750) from cabine where not evaso<=>1;
另请参阅此处以供参考。
SELECT sum(sbc750) FROM cabine where evaso is null or evaso<>1;