0
0
Redisquery~20 mins

Range queries for scoring in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Range Query Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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"
AZRANGEBYSCORE players 50 100
BZRANGE players 50 100
CZREVRANGEBYSCORE players 50 100
DZRANGEBYSCORE players (50 (100
Attempts:
2 left
💡 Hint
Use the command that filters by score range, not by rank.
📝 Syntax
intermediate
2: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"
AZRANGEBYSCORE scores 20 80
BZRANGEBYSCORE scores 20, 80
CZRANGEBYSCORE scores (20 80
DZRANGEBYSCORE scores 20 (80
Attempts:
2 left
💡 Hint
Check for invalid characters or separators in the command.
optimization
advanced
2: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"
AZRANGEBYSCORE leaderboard (90 +inf LIMIT 0 5
BZRANGEBYSCORE leaderboard 90 +inf LIMIT 0 5
CZREVRANGEBYSCORE leaderboard +inf (90 LIMIT 0 5
DZREVRANGEBYSCORE leaderboard +inf 90 LIMIT 0 5
Attempts:
2 left
💡 Hint
Remember that ZREVRANGEBYSCORE returns members in descending score order.
🔧 Debug
advanced
2: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"
AZRANGEBYSCORE only works with integer scores
BZRANGEBYSCORE requires the max score first, then min score
CThe sorted set is empty, so no results
DThe min score is greater than max score; range is invalid
Attempts:
2 left
💡 Hint
Check the order of min and max scores in the command.
🧠 Conceptual
expert
2: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?
AThe first excludes 50 but includes 100; the second includes 50 but excludes 100
BBoth exclude 50 and 100
CThe first includes 50 and excludes 100; the second excludes 50 and includes 100
DBoth include 50 and 100
Attempts:
2 left
💡 Hint
Parentheses before a score mean exclusive bound for that score.