Added the null checks in the SQL criteria.