Skip to content
Advertisement

NULL values not filtered out with WHERE statement

SELECT ID, VOLUME,  TYPEOF(VOLUME) FROM DBT.BASE 

When I select these columns, I see that the results have some NULL values. They don’t seem to be strings. However, when I try to filter the NULL values out with a where statement:

SELECT ID, VOLUME,  TYPEOF(VOLUME) FROM DBT.BASE WHERE VOLUME = NULL

I don’t see any results. What might be the possible causes? I also tried filtering with 'NULL' but that would throw an error since the column type is double.

Advertisement

Answer

use this for only want null recode

SELECT ID, VOLUME,  TYPEOF(VOLUME) FROM DBT.BASE WHERE VOLUME IS NULL
or
SELECT ID, VOLUME,  TYPEOF(VOLUME) FROM DBT.BASE WHERE ISNULL(VOLUME,'') = ''

if you get not null value then use

SELECT ID, VOLUME,  TYPEOF(VOLUME) FROM DBT.BASE WHERE ISNULL(VOLUME,'') <> ''
or 
SELECT ID, VOLUME,  TYPEOF(VOLUME) FROM DBT.BASE WHERE VOLUME IS NOT NULL

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement