0
0
PostgreSQLquery~10 mins

Boolean type behavior in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select all rows where the boolean column is true.

PostgreSQL
SELECT * FROM users WHERE active = [1];
Drag options to blanks, or click blank then click option'
A1
B'true'
CTRUE
D't'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'true' as a string instead of the boolean literal TRUE.
Using 1 which is not a boolean literal in PostgreSQL.
2fill in blank
medium

Complete the code to insert a false boolean value into the column.

PostgreSQL
INSERT INTO settings (enabled) VALUES ([1]);
Drag options to blanks, or click blank then click option'
AFALSE
B'f'
C0
D'false'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'false' as a string instead of the boolean literal FALSE.
Using 0 which is not a boolean literal in PostgreSQL.
3fill in blank
hard

Fix the error in the WHERE clause to correctly filter rows where the boolean column is not true.

PostgreSQL
SELECT * FROM tasks WHERE completed [1] TRUE;
Drag options to blanks, or click blank then click option'
A!=
B<>
C=!
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' which is not standard SQL in PostgreSQL.
Using '==' which is invalid in SQL.
4fill in blank
hard

Fill both blanks to create a query that selects rows where the boolean column is true or null.

PostgreSQL
SELECT * FROM orders WHERE status = [1] OR status IS [2];
Drag options to blanks, or click blank then click option'
ATRUE
BFALSE
CNULL
DNOT NULL
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'FALSE' instead of TRUE.
Using IS NOT NULL instead of IS NULL.
5fill in blank
hard

Fill all three blanks to create a query that counts rows where the boolean column is false and not null.

PostgreSQL
SELECT COUNT(*) FROM logs WHERE flag = [1] AND flag IS NOT [2] AND flag IS NOT [3];
Drag options to blanks, or click blank then click option'
ATRUE
BFALSE
CNULL
DNOT NULL
Attempts:
3 left
💡 Hint
Common Mistakes
Using TRUE instead of FALSE.
Using IS NULL instead of IS NOT NULL.