Challenge - 5 Problems
Range Query Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Retrieve members with scores between 50 and 100
Given a sorted set
players with player names as members and their scores as scores, which Redis command returns all players with scores between 50 and 100 inclusive?Redis
ZADD players 30 "Alice" 60 "Bob" 90 "Charlie" 110 "Diana"
Attempts:
2 left
💡 Hint
Use the command that filters by score range, not by rank.
✗ Incorrect
ZRANGEBYSCORE returns members with scores within the specified range. ZRANGE uses rank indexes, not scores. ZREVRANGEBYSCORE reverses the order but requires the max score first. Parentheses indicate exclusive bounds, so option A excludes 50 and 100.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in this Redis range query
Which option contains a syntax error when trying to get members with scores between 20 and 80 from sorted set
scores?Redis
ZADD scores 10 "x" 30 "y" 70 "z"
Attempts:
2 left
💡 Hint
Check for invalid characters or separators in the command.
✗ Incorrect
Option B uses a comma between scores, which is invalid syntax. Scores must be separated by space only. Options B, C, and D are valid syntax with inclusive or exclusive bounds.
❓ optimization
advanced2:00remaining
Efficiently retrieve top 5 players with scores above 90
You want to get the top 5 players with scores greater than 90 from sorted set
leaderboard. Which command is the most efficient and correct?Redis
ZADD leaderboard 85 "Anna" 92 "Ben" 95 "Cara" 99 "Dave" 100 "Eve" 88 "Fay"
Attempts:
2 left
💡 Hint
Remember that ZREVRANGEBYSCORE returns members in descending score order.
✗ Incorrect
Option C correctly uses ZREVRANGEBYSCORE with exclusive lower bound (90) and upper bound +inf, limiting to 5 results. Option C uses ZRANGEBYSCORE which returns ascending order, not top scores. Option C includes 90 (not strictly greater). Option C uses inclusive 90, including players with score 90.
🔧 Debug
advanced2:00remaining
Why does this range query return no results?
You run the command
ZRANGEBYSCORE games 100 50 on a sorted set games with scores from 10 to 150, but get an empty list. Why?Redis
ZADD games 10 "g1" 50 "g2" 100 "g3" 150 "g4"
Attempts:
2 left
💡 Hint
Check the order of min and max scores in the command.
✗ Incorrect
ZRANGEBYSCORE expects min score first, then max score. Here min=100 and max=50 is invalid, so no members match. Option D is incorrect because min must come first. The set is not empty, and scores can be floats.
🧠 Conceptual
expert2:00remaining
Understanding exclusive and inclusive bounds in Redis range queries
Which option correctly describes the difference between
ZRANGEBYSCORE key (50 100 and ZRANGEBYSCORE key 50 (100?Attempts:
2 left
💡 Hint
Parentheses before a score mean exclusive bound for that score.
✗ Incorrect
In Redis, a parenthesis before a score means exclusive. So (50 excludes 50, 50 includes it. The first command excludes 50 but includes 100. The second includes 50 but excludes 100.