exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 11 discussion

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

HOTSPOT -
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.
You query a database that includes two tables: Project and Task. The Project table includes the following columns:


You need to identify the owner of each task by using the following rules:
✑ Return each task's owner if the task has an owner.
✑ If a task has no owner, but is associated with a project that has an owner, return the project's owner.
✑ Return the value-1for all other cases.
How should you complete the Transact-SQL statement? To answer, select the appropriate Transact-SQL segments in the answer area.
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:
Box 1: COALESCE -
COALESCE evaluates the arguments in order and returns the current value of the first expression that initially does not evaluate to NULL.

Box 2: T.UserID, p.UserID, -1 -
✑ Return each task's owner if the task has an owner.
✑ If a task has no owner, but is associated with a project that has an owner, return the project's owner.
✑ Return the value -1 for all other cases.

Box 3: RIGHT JOIN -
The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1). The result is NULL in the left side when there is no match. Here the right side could be NULL as the projectID of the task could be NULL.
References:
https://msdn.microsoft.com/en-us/library/ms190349.aspx
http://www.w3schools.com/Sql/sql_join_right.asp

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
Tazul
Highly Voted 5 years, 9 months ago
Correct: Left Join
upvoted 33 times
...
chaoxes
Highly Voted 4 years, 9 months ago
I confirm 100% that correct answer is LEFT JOIN. Passed exam today with 970 score and had this question
upvoted 11 times
...
Anirudh_net
Most Recent 3 years, 2 months ago
You didn't count that fact that the Task table is on the left side of the join , not on the right one. Table 2 is on the left side
upvoted 1 times
...
Oooo
4 years, 8 months ago
Guys the correct answer in Left join.(110% sure)
upvoted 2 times
...
stm22
4 years, 10 months ago
must be Left join
upvoted 2 times
...
Joeyboats
4 years, 10 months ago
Left join is correct we want to bring in all tasks not all projects.
upvoted 3 times
...
Backy
4 years, 10 months ago
It cannot be RIGHT JOIN because there could be a task without a project, and RIGHT JOIN on projects would not pick up such tasks LEFT JOIN picks up all tasks, not necessarily all projects
upvoted 3 times
...
CristianCruz
4 years, 12 months ago
Box 1: COALESCE - COALESCE evaluates the arguments in order and returns the current value of the rst expression that initially does not evaluate to NULL. Box 2: T.UserID, p.UserID, -1 - ✑ Return each task's owner if the task has an owner. ✑ If a task has no owner, but is associated with a project that has an owner, return the project's owner. ✑ Return the value -1 for all other cases. Box 3: RIGHT JOIN - The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1). The result is NULL in the left side when there is no match. Here the right side could be NULL as the projectID of the task could be NULL.
upvoted 1 times
Andy7622
4 years, 6 months ago
You didn't count that fact that the Task table is on the left side of the join , not on the right one. Table 2 is on the left side
upvoted 1 times
...
...
Anette
5 years ago
Its correct besides LEFT JOIN
upvoted 1 times
...
trickytree
5 years ago
Has to be a LEFT join surely - we want ALL tasks (LEFT hand table) regardless of whether they are associated with a project.
upvoted 1 times
...
Hamburger
5 years, 2 months ago
left join
upvoted 4 times
...
Robintang0924
5 years, 4 months ago
agreed, left join it is since select result only concerned about task. If we go with right join then for a task that has no project, we will get an all null value row result which doesn't make any sense in any context and requirement.
upvoted 8 times
...
mlourinho
5 years, 6 months ago
The columns selected are concerning Tasks. Therefore we should use LEFT JOIN. Otherwise the result will Induce error.
upvoted 7 times
...
prakash101179
5 years, 7 months ago
Should be left join. Question is about tasks.
upvoted 9 times
...
Tr4ckz
5 years, 8 months ago
RIGHT JOIN is correct, as given in the answer. The task table (left) is containing the potentially empty values and is joined onto the right project table.
upvoted 1 times
Luzix
4 years, 6 months ago
If you choose the right join, the select only will show tasks with a project.
upvoted 2 times
...
Hoglet
4 years, 5 months ago
LEFT OUTER will give you a result set including all the Tasks without a Project. RIGHT OUTER give a result set including all the Projects without a Task. From you question you need a LEFT OUTER JOIN
upvoted 2 times
...
...
M4x
5 years, 8 months ago
Its a LEFT JOIN
upvoted 9 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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago