nerdexam
Microsoft

DP-420 · Question #7

You are developing an application that will use an Azure Cosmos DB Core (SQL) API account as a data source. You need to create a report that displays the top five most ordered fruits as shown in the…

The correct answer is B. SELECT TOP 5 i.name, i.types, i.orders FROM items i WHERE EXISTS(SELECT VALUE t FROM t IN i.types WHERE t.name = 'fruit') ORDER BY i.orders DESC D. SELECT TOP 5 i.name, i.types, i.orders FROM items i WHERE ARRAY_CONTAINS(i.types, {name: 'fruit'}) ORDER BY i.orders DESC. ARRAY_CONTAINS returns a Boolean indicating whether the array contains the specified value. You can check for a partial or full match of an object by using a boolean expression within the Incorrect Answers: A: Default sorting ordering is Ascending. Must use Descending order. C…

Design and implement data models

Question

You are developing an application that will use an Azure Cosmos DB Core (SQL) API account as a data source. You need to create a report that displays the top five most ordered fruits as shown in the following table. A collection that contains aggregated data already exists. The following is a sample document:

Which two queries can you use to retrieve data for the report? Each correct answer presents a complete solution. NOTE: Each correct selection is worth one point. A. B. C. D.

Exhibits

DP-420 question #7 exhibit 1
DP-420 question #7 exhibit 2
DP-420 question #7 exhibit 3
DP-420 question #7 exhibit 4
DP-420 question #7 exhibit 5

Options

  • ASELECT TOP i.name, i.types, i.orders FROM items i WHERE EXISTS(SELECT VALUE t FROM t IN i.types WHERE t.name = 'fruit') ORDER BY i.orders, i.types
  • BSELECT TOP 5 i.name, i.types, i.orders FROM items i WHERE EXISTS(SELECT VALUE t FROM t IN i.types WHERE t.name = 'fruit') ORDER BY i.orders DESC
  • CSELECT TOP i.name, i.types, i.orders FROM items i WHERE EXISTS(SELECT VALUE t FROM t IN i.types WHERE t.name = 'fruit') ORDER BY i.orders DESC
  • DSELECT TOP 5 i.name, i.types, i.orders FROM items i WHERE ARRAY_CONTAINS(i.types, {name: 'fruit'}) ORDER BY i.orders DESC

How the community answered

(63 responses)
  • A
    19% (12)
  • B
    73% (46)
  • C
    8% (5)

Explanation

ARRAY_CONTAINS returns a Boolean indicating whether the array contains the specified value. You can check for a partial or full match of an object by using a boolean expression within the Incorrect Answers: A: Default sorting ordering is Ascending. Must use Descending order. C: Order on Orders not on Type.

Topics

#Cosmos DB SQL API#Querying Data#Top N Queries#ORDER BY / LIMIT / OFFSET

Community Discussion

No community discussion yet for this question.

Full DP-420 Practice