exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 104 discussion

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

SIMULATION -
You have a database that contains the following tables.

You need to create a query that lists the highest-performing salespersons based on the current year-to-date sales period. The query must meet the following requirements:
✑ Return the LastName and SalesYTD for the three salespersons with the highest year-to-date sales values.
✑ Exclude salespersons that have no value for TerritoryID.
Construct the query using the following guidelines:
✑ Use the first letter of a table name as the table alias.
✑ Use two-part column names.
✑ Do not surround object names with square brackets.
✑ Do not use implicit joins.
✑ Use only single quotes for literal text.
Use aliases only if required.


Part of the correct Transact-SQL has been provided in the answer area below. Enter the code in the answer area that resolves the problem and meets the stated goals or requirements. You can add code within the code that has been provided as well as below it.
1 SELECT top 3 lastname,salesYTD
2 FROM Person AS p INNER JOIN SalesPerson AS s
3 ON p.PersonID = s.SalesPersonID
4 WHERE territoryid is null
5 order by salesytd dsec
Use the Check Syntax button to verify your work. Any syntax or spelling errors will be reported by line and character position.

Show Suggested Answer Hide Answer
Suggested Answer: Please see explanation
1 SELECT top 3 lastname,salesYTD
2 FROM Person AS p INNER JOIN SalesPerson AS s
3 ON p.PersonID = s.SalesPersonID
4 WHERE territoryid is not null
5 order by salesytd desc
Note:
On line 4 add a not before null.
On line 5 change dsec to desc.

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
MarcusJB
Highly Voted 4 years, 11 months ago
SELECT TOP(3) p.LastName, s.SalesYTD FROM Person AS p INNER JOIN SalesPerson AS s ON p.PersonId = s.PersonId WHERE S.TerritoryID IS NOT NULL ORDER BY S.SalesYTD DESC;
upvoted 7 times
...
BenAsare
Highly Voted 5 years, 5 months ago
SELECT top(3) p.lastname, s.salesYTD *use two part column naming
upvoted 6 times
anonimdom
5 years, 3 months ago
But *Use aliases only if required. Quite an ambiguous question.
upvoted 2 times
...
Andy7622
4 years, 4 months ago
Actually , the need to use them only where they are required . And the only place we can't omit them is ON clause.
upvoted 2 times
...
...
Vermonster
Most Recent 4 years, 4 months ago
SELECT TOP(3) p.LastName, s.SalesYTD FROM SalesPerson as s INNER JOIN Person as p ON s.personid = p.personid WHERE s.territoryid IS NOT NULL ORDER BY s.salesYTD DESC
upvoted 2 times
...
jortizhuedo
5 years, 1 month ago
select top 3 person.lastname, salesperson.salesYTD from person join salesperson on person.personid=salesperson.personid where territoryid is not null order by salesYTD desc
upvoted 4 times
...
mattia_88
5 years, 6 months ago
Exclude salespersons that have no value for TerritoryID. "WHERE TerritoryID IS NOT NULL"
upvoted 5 times
Jiacheng
5 years, 2 months ago
that's why we say SQL database engine is smart. if column is only shows on specific table, we can use it without using two named convension
upvoted 2 times
...
...
Bartek
5 years, 7 months ago
Should not be s.PersonId = p.PersonId. nevertheless PersonId in SalesPerson table looks like foreign key to Person table...
upvoted 1 times
Andy7622
4 years, 4 months ago
Wrong ! MUST BE ON ps.PersonID = p.PersonID
upvoted 1 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