Challenge - 5 Problems
Boolean Filtering Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Filter rows where a boolean column is TRUE
Given a table
tasks with a boolean column completed, which query returns only the rows where completed is TRUE?PostgreSQL
SELECT * FROM tasks WHERE completed = TRUE;
Attempts:
2 left
💡 Hint
In PostgreSQL, boolean values are TRUE or FALSE, not numbers or strings.
✗ Incorrect
Option D uses the correct SQL syntax to filter boolean TRUE values. Option D works but is less idiomatic. Option D compares to a string, which is invalid. Option D compares to a number, which is invalid in PostgreSQL boolean context.
❓ query_result
intermediate2:00remaining
Filter rows where a boolean column is FALSE
Which query correctly returns rows where the boolean column
active is FALSE in PostgreSQL?PostgreSQL
SELECT * FROM users WHERE active = FALSE;
Attempts:
2 left
💡 Hint
Use the IS operator for boolean checks in PostgreSQL.
✗ Incorrect
Option A is the correct and idiomatic way to check for FALSE boolean values. Option A works but is less preferred. Options B and D compare to string and number, which are invalid for boolean columns.
📝 Syntax
advanced2:00remaining
Identify the syntax error in boolean filtering
Which option contains a syntax error when filtering a boolean column
is_verified for TRUE values?PostgreSQL
SELECT * FROM accounts WHERE is_verified = TRUE;
Attempts:
2 left
💡 Hint
Boolean values in PostgreSQL are not strings.
✗ Incorrect
Option C compares the boolean column to a string 'TRUE', which causes a syntax error. The other options use valid boolean expressions.
❓ query_result
advanced2:00remaining
Filter rows where boolean column is NULL or FALSE
Given a boolean column
subscribed that can be TRUE, FALSE, or NULL, which query returns rows where subscribed is either FALSE or NULL?PostgreSQL
SELECT * FROM newsletter WHERE subscribed IS FALSE OR subscribed IS NULL;
Attempts:
2 left
💡 Hint
Use IS NULL to check for NULL values in SQL.
✗ Incorrect
Option A correctly uses IS FALSE and IS NULL to filter both FALSE and NULL values. Option A mixes = FALSE (valid) with IS NULL (valid), but = FALSE can behave differently if NULLs exist. Option A uses = NULL which is invalid. Option A excludes NULLs because NOT NULL is unknown.
🧠 Conceptual
expert2:00remaining
Understanding boolean filtering with NOT operator
What is the result of this query on a table
orders with a boolean column shipped that can be TRUE, FALSE, or NULL?SELECT * FROM orders WHERE NOT shipped;Attempts:
2 left
💡 Hint
In SQL, NOT NULL evaluates to UNKNOWN, which is treated as false in WHERE.
✗ Incorrect
The NOT operator applied to NULL results in UNKNOWN, which filters out those rows. So only rows where shipped is FALSE are returned.