0
0
PostgreSQLquery~20 mins

NULLIF function behavior in PostgreSQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
NULLIF Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:30remaining
What is the output of NULLIF when values are equal?
Consider the query:
SELECT NULLIF(5, 5) AS result;

What is the value of result?
PostgreSQL
SELECT NULLIF(5, 5) AS result;
AError
B5
C0
DNULL
Attempts:
2 left
💡 Hint
NULLIF returns NULL if both arguments are equal.
query_result
intermediate
1:30remaining
What does NULLIF return when values differ?
What is the output of this query?
SELECT NULLIF('apple', 'orange') AS result;
PostgreSQL
SELECT NULLIF('apple', 'orange') AS result;
A'apple'
BNULL
C'orange'
DError
Attempts:
2 left
💡 Hint
NULLIF returns the first argument if they are not equal.
🧠 Conceptual
advanced
2:00remaining
How does NULLIF behave with NULL arguments?
What is the result of this query?
SELECT NULLIF(NULL, NULL) AS result;
PostgreSQL
SELECT NULLIF(NULL, NULL) AS result;
ATRUE
BError
CNULL
DFALSE
Attempts:
2 left
💡 Hint
NULL compared to anything is unknown, but NULLIF treats NULL arguments specially.
query_result
advanced
2:00remaining
What is the output of NULLIF with expressions?
Evaluate the query:
SELECT NULLIF(10/2, 5) AS result;
PostgreSQL
SELECT NULLIF(10/2, 5) AS result;
A5
BNULL
C2
DError
Attempts:
2 left
💡 Hint
Calculate the first expression and compare to the second argument.
📝 Syntax
expert
2:30remaining
Which NULLIF usage causes a syntax error?
Identify the option that will cause a syntax error in PostgreSQL:
ASELECT NULLIF(1);
BSELECT NULLIF('a', 'b');
CSELECT NULLIF(1, 1) FROM dual;
DSELECT NULLIF(NULL, 0);
Attempts:
2 left
💡 Hint
Check the number of arguments NULLIF requires.