我想说的是声明
where date_end not in (null, 229)
我已经尝试过
where date_end not in (229) and date_end is not null
我也尝试过
where date_end is not null or date_end not (229)
这是必需的,因为我在date_end
语句中使用to_date
来创建日期。我想忽略229,因为leap年和空值,因为它不会在to_date
语句中响应。
答案 0 :(得分:4)
您可以尝试:
where NVL(date_end, 229) != 229
答案 1 :(得分:2)
您可以简单地写:
where date_end <> 229
这也会滤除NULL
值。
not in
也是如此:
where date_end not in (229)
如果要明确,请使用and
:
where date_end <> 229 and date_end is not null
答案 2 :(得分:0)
如果存在除229以外的其他非空值,这将是一个更好的选择。
( where date_end is null and date_end not in (229));
答案 3 :(得分:0)
只需:
where date_end not in ( 229 )
NULL NOT IN ( 229 )
始终求值为NULL,这等效于WHERE子句中的FALSE。不需要额外的NOT NULL检查。
请检查一个简单的演示:http://www.sqlfiddle.com/#!4/358b6e/2
CREATE table test(
date_end int
);
INSERT ALL
INTO test VALUES( null )
INTO test VALUES( 229 )
INTO test VALUES( 123 )
SELECT null FROM dual;
SELECT * FROM test;
| DATE_END |
|----------|
| (null) |
| 229 |
| 123 |
SELECT * FROM test
WHERE date_end NOT IN ( 229 )
| DATE_END |
|----------|
| 123 |
答案 4 :(得分:0)
这对我有用,看看是否对您有用:
where date_end <>229 and date_end is not null;