DP-900 · Question #306
You have an Azure SQL database that contains tables for customers and orders. You need to create a query that will return the orders placed by each customer. Which two Transact-SOL statements should…
The correct answer is C. JOIN D. ORDERBY. To retrieve orders associated with each customer, a query must combine rows from two tables and organize the output. JOIN links the tables and ORDER BY sequences the results.
Question
Options
- AINDEX
- BEXISTS
- CJOIN
- DORDERBY
- ESELECT
How the community answered
(21 responses)- A10% (2)
- B5% (1)
- C81% (17)
- E5% (1)
Why each option
To retrieve orders associated with each customer, a query must combine rows from two tables and organize the output. JOIN links the tables and ORDER BY sequences the results.
INDEX is a database object created with CREATE INDEX, not a query clause; it cannot appear inside a SELECT statement to filter or join data.
EXISTS is a subquery predicate used to test for the presence of rows, not to join two tables and return combined columns from both.
JOIN combines rows from the customers table and the orders table based on a shared key, which is required to associate each order with its customer.
ORDER BY sequences the result set - typically by customer identifier - so that orders grouped under each customer are returned in a meaningful, organized order.
While SELECT is required in any query, it alone does not establish the relationship between the customers and orders tables; the question asks for the two statements that specifically address joining and organizing the data.
Concept tested: T-SQL multi-table query with JOIN and ORDER BY
Source: https://learn.microsoft.com/en-us/sql/t-sql/queries/select-transact-sql
Topics
Community Discussion
No community discussion yet for this question.