0
0
DynamoDBquery~10 mins

Query result ordering (ascending, descending) in DynamoDB - Interactive Code Practice

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

Complete the code to query items in ascending order by sort key.

DynamoDB
response = table.query(
    KeyConditionExpression=Key('UserId').eq('123'),
    ScanIndexForward=[1]
)
Drag options to blanks, or click blank then click option'
ATrue
BFalse
C'ASC'
D'DESC'
Attempts:
3 left
💡 Hint
Common Mistakes
Using False instead of True for ascending order.
Using string values like 'ASC' which are invalid.
2fill in blank
medium

Complete the code to query items in descending order by sort key.

DynamoDB
response = table.query(
    KeyConditionExpression=Key('UserId').eq('456'),
    ScanIndexForward=[1]
)
Drag options to blanks, or click blank then click option'
A'ASC'
BFalse
CTrue
D'DESC'
Attempts:
3 left
💡 Hint
Common Mistakes
Using True instead of False for descending order.
Using string values like 'DESC' which are invalid.
3fill in blank
hard

Fix the error in the query to order results ascending by sort key.

DynamoDB
response = table.query(
    KeyConditionExpression=Key('UserId').eq('789'),
    ScanIndexForward=[1]
)
Drag options to blanks, or click blank then click option'
A'True'
B'False'
CFalse
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using string 'True' or 'False' instead of boolean True or False.
Confusing ascending and descending values.
4fill in blank
hard

Fill both blanks to query items for UserId '101' in descending order.

DynamoDB
response = table.query(
    KeyConditionExpression=Key([1]).eq([2]),
    ScanIndexForward=False
)
Drag options to blanks, or click blank then click option'
A'UserId'
B'101'
C'SortKey'
D'202'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the sort key name instead of the partition key.
Using a wrong user ID value.
5fill in blank
hard

Fill all three blanks to query items for UserId '202' in ascending order with correct key and value.

DynamoDB
response = table.query(
    KeyConditionExpression=Key([1]).eq([2]),
    ScanIndexForward=[3]
)
Drag options to blanks, or click blank then click option'
A'UserId'
B'202'
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using False instead of True for ascending order.
Using wrong key or value strings.