0
0
PostgreSQLquery~20 mins

Boolean column filtering patterns in PostgreSQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Boolean Filtering Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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;
ASELECT * FROM tasks WHERE completed = TRUE;
BSELECT * FROM tasks WHERE completed = 'true';
CSELECT * FROM tasks WHERE completed = 1;
DSELECT * FROM tasks WHERE completed IS TRUE;
Attempts:
2 left
💡 Hint
In PostgreSQL, boolean values are TRUE or FALSE, not numbers or strings.
query_result
intermediate
2: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;
ASELECT * FROM users WHERE active IS FALSE;
BSELECT * FROM users WHERE active = 'false';
CSELECT * FROM users WHERE active = FALSE;
DSELECT * FROM users WHERE active = 0;
Attempts:
2 left
💡 Hint
Use the IS operator for boolean checks in PostgreSQL.
📝 Syntax
advanced
2: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;
ASELECT * FROM accounts WHERE is_verified IS TRUE;
BSELECT * FROM accounts WHERE is_verified IS NOT FALSE;
CSELECT * FROM accounts WHERE is_verified = 'TRUE';
DSELECT * FROM accounts WHERE is_verified = TRUE;
Attempts:
2 left
💡 Hint
Boolean values in PostgreSQL are not strings.
query_result
advanced
2: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;
ASELECT * FROM newsletter WHERE subscribed IS FALSE OR subscribed IS NULL;
BSELECT * FROM newsletter WHERE subscribed = FALSE OR subscribed IS NULL;
CSELECT * FROM newsletter WHERE subscribed = FALSE OR subscribed = NULL;
DSELECT * FROM newsletter WHERE NOT subscribed;
Attempts:
2 left
💡 Hint
Use IS NULL to check for NULL values in SQL.
🧠 Conceptual
expert
2: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;
AReturns rows where shipped is FALSE or NULL
BReturns rows where shipped is FALSE only
CReturns rows where shipped is NULL only
DReturns rows where shipped is TRUE only
Attempts:
2 left
💡 Hint
In SQL, NOT NULL evaluates to UNKNOWN, which is treated as false in WHERE.