Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.
After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.
A database has two tables as shown in the following database diagram:
You need to list all provinces that have at least two large cities. A large city is defined as having a population of at least one million residents. The query must return the following columns:
– tblProvince.ProvinceId
– tblProvince.ProvinceName
– a derived column named LargeCityCount that presents the total count of large cities for the province
Solution: You run the following Transact-SQL statement:
Does the solution meet the goal?
A . Yes
B . No
Answer: A
Explanation:
The requirement to list all provinces that have at least two large cities is meet by the WHERE CitySummary.LargeCityCount >=2 clause.
CROSS APPLY willwork fine here.
Note:
The APPLY operator allows you to invoke a table-valued function for each row returned by an outer table expression of a query. The table-valued function acts as the right input and the outer table expression acts as the left input. The right input is evaluated for each row from the left input and the rows produced are combined for the final output. The list of columns produced by the APPLY operator is the set of columns in the left input followed by the list of columns returned by the right input.
There are two forms of APPLY: CROSS APPLY and OUTER APPLY. CROSS APPLY returns only rows from the outer table that produce a result set from the table-valued function. OUTER APPLY returns both rows that produce a result set, and rows that do not, with NULL values in the columns produced by the table-valued function.
References: https://technet.microsoft.com/en-us/library/ms175156(v=sql.105).aspx
Latest 70-761 Dumps Valid Version with 212 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund