Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do both is not null and a not in statement in sql (oracle)?

I am trying to say the statement

where date_end not in (null, 229)

I have already tried

where date_end not in (229) and date_end is not null

I have also tried

where date_end is not null or date_end not (229)

This is necessary because I am using the date_end in a to_date statement to create a date. I want to ignore 229 because of leap years and nulls because it will not respond in the to_date statement.

like image 891
Rebecca Gonzalez Avatar asked Dec 16 '25 19:12

Rebecca Gonzalez


2 Answers

You can try:

where NVL(date_end, 229) != 229
like image 139
Goran Kutlaca Avatar answered Dec 19 '25 11:12

Goran Kutlaca


You can simply write:

where date_end <> 229

This also filters out NULL values.

The same is true for not in:

where date_end not in (229)

If you want to be explicit, use and:

where date_end <> 229 and date_end is not null
like image 36
Gordon Linoff Avatar answered Dec 19 '25 12:12

Gordon Linoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!