Fix SQL issue when using 'IS NOT NULL'