Here is how you can solve this using a single WHERE clause:

WHERE (@myParm = value1 AND MyColumn IS NULL)
OR  (@myParm = value2 AND MyColumn IS NOT NULL)
OR  (@myParm = value3)

A naïve usage of the CASE statement does not work, by this I mean the following:

SELECT Field1, Field2 FROM MyTable
WHERE CASE @myParam
    WHEN value1 THEN MyColumn IS NULL
    WHEN value2 THEN MyColumn IS NOT NULL
    WHEN value3 THEN TRUE
END

It is possible to solve this using a case statement, see onedaywhen's answer

Answer from Patrick McDonald on Stack Overflow
🌐
W3Schools
w3schools.com › sql › sql_null_values.asp
SQL NULL Values - IS NULL and IS NOT NULL
The following SQL lists all customers ... · Tip: Always use IS NULL to look for NULL values. The IS NOT NULL operator is used to test for non-empty values (NOT NULL values)....
Discussions

IS NULL vs = NULL in where clause + SQL Server - Stack Overflow
How to check a value IS NULL [or] = @param (where @param is null) Ex: Select column1 from Table1 where column2 IS NULL => works fine If I want to replace comparing value (IS NULL) with @param.... More on stackoverflow.com
🌐 stackoverflow.com
sql server - Include in where clause if the value is not null - Stack Overflow
I just return values based on inputted parameters, if the item description is null, I don't want to include that in the where clause. Like item description, all other cases were same. ALTER Proce... More on stackoverflow.com
🌐 stackoverflow.com
May 22, 2017
mysql - WHERE Clause only IF NOT NULL - Stack Overflow
0 mysql conditional where clause if value is null or not · 2 WHERE If condition is not met get all values including NULL More on stackoverflow.com
🌐 stackoverflow.com
sql server - Using IS NULL in CASE Expression in WHERE Clause - Database Administrators Stack Exchange
Too localized - this could be because ... or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background). Closed 8 years ago. ... I have a WHERE clause that I want to use a CASE expression in. However, my CASE expression needs to check if a field IS NULL... More on dba.stackexchange.com
🌐 dba.stackexchange.com
🌐
Mimo
mimo.org › glossary › sql › is-not-null
SQL IS NOT NULL Condition: Syntax, Usage, and Examples
Use SQL IS NOT NULL in a WHERE clause to filter out records that contain empty or missing values in a column.
🌐
MSSQLTips
mssqltips.com › home › sql where is not null examples
SQL WHERE IS NOT NULL Examples
March 13, 2023 - As such, we no longer need them in the current table, and we can delete them. DELETE FROM MyEmployeeTable WHERE email IS NOT NULL; GO · Let’s run a simple SELECT * query to see the new results. ... The WHERE clause in SQL is used to specify the criteria for selecting data from a database table.
🌐
BeginnersBook
beginnersbook.com › 2018 › 12 › sql-null-values-check
SQL NULL Check in Where clause – IS NULL and IS NOT NULL
December 2, 2018 - In SQL Where clause tutorial, we ... clause for conditions. However when a column (field) of table has null values then such operators do not work on those columns, in such case we have to use IS NULL & IS NOT NULL operators for the null check....
🌐
DB Vis
dbvis.com › thetable › sql-is-not-null-condition-definitive-guide
SQL IS NOT NULL Condition: Definitive Guide
August 13, 2025 - In most cases, the IS NOT NULL SQL condition is used in WHERE clauses, like this:
Find elsewhere
🌐
Quest Blog
blog.quest.com › home › toad data point tutorials: sql where clause null values
Toad Data Point Tutorials: SQL Where Clause Null Values - The Quest Blog
October 1, 2025 - The syntax is where COLUMN_NAME IS NULL or COLUMN_NAME IS NOT NULL. The obvious syntax would be COLUMN_NAME = NULL or COLUMN_NAME <> NULL. However, this syntax does not throw an error nor return any rows as it should.
Top answer
1 of 4
8

I think you are making it harder than it should be.

If @UserRole is 'Analyst' then also SupervisorApprovedBy should be null? Else return everything?

WHERE (@UserRole = 'Analyst' AND SupervisorApprovedBy IS NULL ) 
OR (ISNULL(@UserRole, '') <> 'Analyst')
2 of 4
13

The problem is likely the comparison to NULL, as explained in David Spillett's answer above. When @UserRole = 'Analyst', the comparison SupervisorApprovedBy = NULL will give UNKNOWN (and the row won't pass the WHERE test).

You can rewrite with nested CASE expressions:

WHERE 1 =
  CASE 
    WHEN @UserRole = 'Analyst' THEN 
        CASE WHEN SupervisorApprovedBy IS NULL THEN 1 END
    WHEN SupervisorApprovedBy IS NOT NULL THEN 1
  END

Or a complicated CASE expression:

WHERE 1 =
  CASE 
    WHEN @UserRole = 'Analyst' AND SupervisorApprovedBy IS NULL THEN 1
    WHEN @UserRole = 'Analyst' THEN 0
    WHEN SupervisorApprovedBy IS NOT NULL THEN 1
  END

or with a bit more easy to understand AND / OR:

WHERE 
    @UserRole = 'Analyst'  AND SupervisorApprovedBy IS NULL 
 OR @UserRole <> 'Analyst' AND SupervisorApprovedBy IS NOT NULL 
 OR @UserRole IS NULL      AND SupervisorApprovedBy IS NOT NULL 

Another issue is that SupervisorApprovedBy = SupervisorApprovedBy (and the equivalent SupervisorApprovedBy IS NOT NULL I used above) will not give you "all data". The rows where SupervisorApprovedBy is null will not be returned. If you do want them all, the conditions should be all adjusted:

WHERE 1 =
  CASE 
    WHEN @UserRole = 'Analyst' THEN 
        CASE WHEN SupervisorApprovedBy IS NULL THEN 1 END
    ELSE 1
  END


WHERE 1 =
  CASE 
    WHEN @UserRole = 'Analyst' AND SupervisorApprovedBy IS NULL THEN 1
    WHEN @UserRole = 'Analyst' THEN 0
    ELSE 1
  END


WHERE 
    @UserRole = 'Analyst'  AND SupervisorApprovedBy IS NULL 
 OR @UserRole <> 'Analyst' 
 OR @UserRole IS NULL       
🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-is-not-null-operator
SQL IS NOT NULL Operator - GeeksforGeeks
July 23, 2025 - In SQL, the IS NOT NULL operator is a powerful logical operator used to filter data by identifying rows with non-NULL values in specified columns. This operator works opposite to the IS NULL operator, returning TRUE for rows where the value ...
🌐
SQL Shack
sqlshack.com › working-with-sql-null-values
Working with SQL NULL values
May 19, 2021 - The IS NULL condition is used to ... column values are equal to NULL. The IS NOT NULL condition is used to return the rows that contain non-NULL values in a column....
🌐
IBM
ibm.com › docs › en › db2-for-zos › 12.0.0
Application programming and SQL - Handling null values
January 7, 2026 - Example 1: Selecting rows that contain null in a column · To select the values for all rows that contain a null value for the manager number, you can issue the following statement: SELECT DEPTNO, DEPTNAME, ADMRDEPT FROM DSN8C10.DEPT WHERE MGRNO IS NULL ... The following table shows the result. Example 2: Selecting rows that do not contain a null value · To get the rows that do not have a null value for the manager number, you can change the WHERE clause in the previous example like this:
🌐
DotFactory
dofactory.com › sql › where-isnull
SQL IS NULL | IS NOT NULL
A WHERE IS NULL clause returns rows with columns that have NULL values. WHERE IS NOT NULL returns rows with column values that are not NULL.
🌐
SQLServerCentral
sqlservercentral.com › home › topics › isnull in a where clause
Isnull in a Where Clause – SQLServerCentral Forums
July 12, 2020 - drop table if exists test_tblinfo; go create table test_tblinfo(fldinfo int); go insert test_tblinfo values (null), (1); declare @parameter int=null; /* original */ SELECT * FROM test_tblinfo WHERE fldinfo=ISNULL(@parameter,fldinfo); /* incorrect */ SELECT * FROM test_tblinfo WHERE @parameter IS NULL OR fldinfo = @parameter; /* correct */ SELECT * FROM test_tblinfo WHERE fldinfo IS NOT NULL OR fldinfo = @parameter; Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können ... Any function against a table column in a WHERE clause is not a good idea and is potentially bad for performance, because it prevents index seeks for that comparison.
🌐
LearnSQL.com
learnsql.com › blog › not-null-constraint-sql
What Is a NOT NULL Constraint in SQL? | LearnSQL.com
The previous condition is wrong because we can’t use the ‘=’ operator against the NULL value – a very frequent mistake. The correct way to identify a NULL value is using the ‘IS NULL’ operator; the correct WHERE clause is: ... Another important point is the value returned by the logical condition when one of the operand values involved is a NULL.
🌐
Reddit
reddit.com › r/sql › using "where" statement is removing null values, help?
r/SQL on Reddit: Using "WHERE" Statement is removing Null Values, help?
January 7, 2019 -

Hi All,

I'm working in Microsoft Access 2010 and a query i've created is giving me some issues. Basically, I have set up the query to select all records that do not contain the letter 'R' by including the phrase:

SELCECT *
FROM 
WHERE Field Is Not Like '*R*';

However, some records with are null values in Field are not being selected, but not all records. I've revised the where clause to say:

WHERE (Field IS NULL OR Field Is Not Like '*R*');

and that seems to fix the issue.

Can anyone explain why I need that extra statement? I suspect it's some weird issue with the wildcards around the R in my statement, but I would think if the value in Field doesn't have an 'R' in it anywhere, it should select that record.