SQLite: Using NULLIF in WHERE clause not filtering out expected results
I've hit a wall trying to I'm trying to configure I've been banging my head against this for hours. I'm working with SQLite version 3.36.0 and I'm trying to filter out rows from my `orders` table where the `discount` is either `NULL` or `0`. I thought using the `NULLIF` function would help, but it seems like it's not behaving as I expected. Hereβs the query I wrote: ```sql SELECT order_id, total_amount, discount FROM orders WHERE NULLIF(discount, 0) IS NULL; ``` I expected this to return all rows where `discount` is either `NULL` or `0`, but I noticed that it returns rows where `discount` is not `NULL` but greater than `0`. For example, I have a row with `discount` set to `5` that still appears in the results. Iβve also tried breaking it down to see if the scenario was with `NULLIF` by running this simpler query: ```sql SELECT order_id, total_amount, discount FROM orders WHERE discount IS NULL OR discount = 0; ``` This simpler query works fine and returns the expected results. I checked the data types, and `discount` is definitely a `REAL`. Iβm puzzled why `NULLIF` would behave this way in the context of my WHERE clause. Is there something specific about how SQLite evaluates `NULLIF` that I'm missing? Any insight into this behavior would be greatly appreciated! I'm working in a macOS environment. I'm working on a web app that needs to handle this. For reference, this is a production service. Thanks, I really appreciate it!