0
0
SQLquery~20 mins

NULL in AND, OR, NOT logic in SQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SQL NULL Logic Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:30remaining
Output of AND with NULL
What is the result of the following SQL expression?

SELECT TRUE AND NULL AS result;
SQL
SELECT TRUE AND NULL AS result;
ASyntax Error
BTRUE
CFALSE
DNULL
Attempts:
2 left
💡 Hint
Remember that NULL means unknown in SQL logic.
query_result
intermediate
1:30remaining
Output of OR with NULL
What is the result of this SQL expression?

SELECT FALSE OR NULL AS result;
SQL
SELECT FALSE OR NULL AS result;
ATRUE
BNULL
CFALSE
DRuntime Error
Attempts:
2 left
💡 Hint
Think about how OR behaves when one operand is unknown.
query_result
advanced
1:30remaining
Output of NOT with NULL
What is the result of this SQL expression?

SELECT NOT NULL AS result;
SQL
SELECT NOT NULL AS result;
ASyntax Error
BFALSE
CNULL
DTRUE
Attempts:
2 left
💡 Hint
NOT reverses TRUE to FALSE and FALSE to TRUE, but what about NULL?
🧠 Conceptual
advanced
2:00remaining
Understanding NULL in complex AND/OR expressions
Consider the expression:

SELECT (TRUE OR NULL) AND FALSE AS result;

What is the output?
SQL
SELECT (TRUE OR NULL) AND FALSE AS result;
AFALSE
BTRUE
CNULL
DSyntax Error
Attempts:
2 left
💡 Hint
Evaluate the OR part first, then AND with FALSE.
🧠 Conceptual
expert
2:30remaining
Behavior of NULL in NOT combined with AND and OR
What is the result of this SQL expression?

SELECT NOT (FALSE AND NULL) OR (NULL AND TRUE) AS result;
SQL
SELECT NOT (FALSE AND NULL) OR (NULL AND TRUE) AS result;
ATRUE
BFALSE
CNULL
DRuntime Error
Attempts:
2 left
💡 Hint
Evaluate inside parentheses first, then apply NOT and OR.