0
0
PostgreSQLquery~20 mins

Standard comparison operators in PostgreSQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of Standard Comparison Operators
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:00remaining
Output of a simple equality comparison
What is the output of this SQL query?

SELECT 5 = 5 AS result;
PostgreSQL
SELECT 5 = 5 AS result;
A5
Btrue
CSyntax error
Dfalse
Attempts:
2 left
💡 Hint
The '=' operator checks if two values are equal and returns a boolean.
query_result
intermediate
1:30remaining
Result of greater than comparison in WHERE clause
Given a table numbers with a column value, what rows will this query return?

SELECT value FROM numbers WHERE value > 10;

Assuming the table has values: 5, 10, 15, 20.
PostgreSQL
SELECT value FROM numbers WHERE value > 10;
A10, 15, 20
B5, 10
C15, 20
D5, 15, 20
Attempts:
2 left
💡 Hint
The '>' operator selects values strictly greater than 10.
📝 Syntax
advanced
1:30remaining
Identify the syntax error in comparison
Which option contains a syntax error in using comparison operators in PostgreSQL?
ASELECT * FROM users WHERE age =! 30;
BSELECT * FROM users WHERE age != 30;
CSELECT * FROM users WHERE age > 30;
DSELECT * FROM users WHERE age <> 30;
Attempts:
2 left
💡 Hint
Check the order of symbols in the comparison operator.
query_result
advanced
1:00remaining
Output of combined comparison with AND
What is the output of this query?

SELECT (5 > 3) AND (2 = 2) AS result;
PostgreSQL
SELECT (5 > 3) AND (2 = 2) AS result;
Atrue
Bfalse
CSyntax error
DNULL
Attempts:
2 left
💡 Hint
Both comparisons must be true for AND to return true.
query_result
expert
1:30remaining
Understanding NULL in comparison operators
What is the result of this query?

SELECT NULL = NULL AS result;
PostgreSQL
SELECT NULL = NULL AS result;
Atrue
Bfalse
CSyntax error
DNULL
Attempts:
2 left
💡 Hint
In SQL, NULL means unknown, so comparing NULL to NULL is not true or false.