exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 76 discussion

Actual exam question from Microsoft's 70-761
Question #: 76
Topic #: 1
[All 70-761 Questions]

DRAG DROP -
Note: This question is part of a series of questions that use the same scenario. For your convenience, the scenario is repeated in each question. Each question presents a different goal and answer choices, but the text of the scenario is exactly the same in each question in this series.

Start of repeated scenario -
You have a database that contains the tables shown in the exhibit. (Click the Exhibit button.)

You review the Employee table and make the following observations:
✑ Every record has a value in the ManagerID except for the Chief Executive Officer (CEO).
✑ The FirstName and MiddleName columns contain null values for some records.
✑ The valid values for the Title column are Sales Representative manager, and CEO.
You review the SalesSummary table and make the following observations:
✑ The ProductCode column contains two parts: The first five digits represent a product code, and the last seven digits represent the unit price. The unit price uses the following pattern: ####.##.
✑ You observe that for many records, the unit price portion of the ProductCode column contains values.
The RegionCode column contains NULL for some records.

✑ Sales data is only recorded for sales representatives.
You are developing a series of reports and procedures to support the business. Details for each report or procedure follow.
Sales Summary report: This report aggregates data by year and quarter. The report must resemble the following table.

Sales Manager report: This report lists each sales manager and the total sales amount for all employees that report to the sales manager.
Sales by Region report: This report lists the total sales amount by employee and by region. The report must include the following columns: EmployeeCode,
MiddleName, LastName, RegionCode, and SalesAmount. If MiddleName is NULL, FirstName must be displayed. If both FirstName and MiddleName have null values, the world Unknown must be displayed/ If RegionCode is NULL, the word Unknown must be displayed.
Report1: This report joins data from SalesSummary with the Employee table and other tables. You plan to create an object to support Report1. The object has the following requirements:
✑ be joinable with the SELECT statement that supplies data for the report
✑ can be used multiple times with the SELECT statement for the report
✑ be usable only with the SELECT statement for the report
✑ not be saved as a permanent object
Report2: This report joins data from SalesSummary with the Employee table and other tables.
You plan to create an object to support Report1. The object has the following requirements:
✑ be joinable with the SELECT statement that supplies data for the report
✑ can be used multiple times for this report and other reports
✑ accept parameters
✑ be saved as a permanent object
Sales Hierarchy report: This report aggregates rows, creates subtotal rows, and super-aggregates rows over the SalesAmount column in a single result-set. The report uses SaleYear, SaleQuarter, and SaleMonth as a hierarchy. The result set must not contain a grand total or cross-tabulation aggregate rows.
Current Price Stored Procedure: This stored procedure must return the unit price for a product when a product code is supplied. The unit price must include a dollar sign at the beginning. In addition, the unit price must contain a comma every three digits to the left of the decimal point, and must display two digits to the left of the decimal point. The stored procedure must not throw errors, even if the product code contains invalid data.

End of Repeated Scenario -
You are creating the queries for Report1 and Report2.
You need to create the objects necessary to support the queries.
Which object should you use to join the SalesSummary table with the other tables that each report uses? To answer, drag the appropriate objects to the correct reports. each object may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
Box 1: common table expression (CTE)
A common tableexpression (CTE) can be thought of as a temporary result set that is defined within the execution scope of a single SELECT, INSERT, UPDATE,
DELETE, or CREATE VIEW statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. Unlike a derived table, a CTE can be self-referencing and can be referenced multiple times in the same query.
A CTE can be used to:
✑ Create a recursive query. For more information, see Recursive Queries Using CommonTable Expressions.
✑ Substitute for a view when the general use of a view is not required; that is, you do not have to store the definition in metadata.
✑ Enable grouping by a column that is derived from a scalar subselect, or a function that is either not deterministic or has external access.
✑ Reference the resulting table multiple times in the same statement.
From Scenario: Report1: This report joins data from SalesSummary with the Employee table and other tables. You plan to create an object to support Report1.
The object has the following requirements:
✑ be joinable with the SELECT statement that supplies data for the report can be used multiple times with the SELECT statement for the report

✑ be usable only with the SELECT statement for the report
✑ not be savedas a permanent object

Box 2: view -
From scenario: Report2: This report joins data from SalesSummary with the Employee table and other tables.
You plan to create an object to support Report1. The object has the following requirements:
✑ be joinable with theSELECT statement that supplies data for the report
✑ can be used multiple times for this report and other reports
✑ accept parameters
✑ be saved as a permanent object
References:
https://technet.microsoft.com/en-us/library/ms190766(v=sql.105).aspx

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
safiullah
Highly Voted 5 years, 10 months ago
I think the second object should be a "Table Valued Function" because it is stored permanently in the database and can be used with other queries as well as it can accept parameters. The answer given chose "View" which is wrong because "Views" can not accept parameters.
upvoted 42 times
Billybob0604
4 years, 5 months ago
that's right. see https://www.mssqltips.com/sqlservertip/5147/limitations-when-working-with-sql-server-views/
upvoted 1 times
...
...
prakash101179
Highly Voted 5 years, 9 months ago
Yeah, Second option should be 'Table Valued Function'
upvoted 7 times
...
Kiruu23
Most Recent 4 years, 10 months ago
First one is CTE and second one should be Table valued functions not view Because view does not accept parameters but TVF does.
upvoted 1 times
...
Anette
5 years, 1 month ago
Also first is wrong. It must be temporary table - its the only one not to be saved permanent
upvoted 1 times
Anette
5 years, 1 month ago
Sorry, even CTE is temp and can be used multiple times with the select statement. Its CTE
upvoted 3 times
...
...
Jiacheng
5 years, 4 months ago
CTE cannot be used with multiple select statement, only one select right after CTE declaration
upvoted 1 times
Jiacheng
5 years, 4 months ago
and to be honest, I think first one should be temp table
upvoted 2 times
Barbedx
5 years, 4 months ago
Question about multiple usage in one SELECT statement, cte able to do it. also, its not be saved as tempora object.
upvoted 6 times
...
...
...
anonimdom
5 years, 5 months ago
For the 1st object, isn't it a subquery/derived table? As per the requirement, the object can be used only with the select statement (not with miltiple statements). The CTE can be used with multiple select statements.
upvoted 1 times
Barbedx
5 years, 4 months ago
t be clear - it can be used in one select statement and in subqueries
upvoted 1 times
...
...
BenAsare
5 years, 7 months ago
A view does not accept parameters but a TVF does!
upvoted 5 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...