exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 89 discussion

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

You have a database that stores information about server and application errors. The database contains the following table:

Servers -


Errors -

You need to return all unique error log messages and the server where the error occurs most often.
Which Transact-SQL statement should you run?

A.

B.

C.

D.

Show Suggested Answer Hide Answer
Suggested Answer: A

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
Bartek
Highly Voted 5 years, 8 months ago
B correct, again sample code DROP TABLE #ERRORS CREATE TABLE #ERRORS ( ERRORID INT PRIMARY KEY, SERVERID INT, OCCURENCES INT, LOGMESSAGE NVARCHAR(MAX) ) INSERT INTO #ERRORS (ERRORID, SERVERID, OCCURENCES, LOGMESSAGE) VALUES (1, 1,3,'ERROR1'), (2,1,2,'ERROR2'), (3,1,10,'ERROR2'), (4,2,4,'ERROR2'), (5,2,14,'ERROR2'), (6,2,24,'ERROR1'), (7,3,10,'ERROR3'), (8,3,24,'ERROR3') SELECT DISTINCT SERVERID, LOGMESSAGE FROM #ERRORS AS E1 WHERE OCCURENCES > ALL ( SELECT E2.OCCURENCES FROM #ERRORS AS E2 WHERE E2.LOGMESSAGE = E1.LOGMESSAGE AND E2.SERVERID <> E1.SERVERID) SELECT DISTINCT SERVERID, LOGMESSAGE FROM #ERRORS AS E1 WHERE LOGMESSAGE IN ( SELECT TOP 1 E2.LOGMESSAGE FROM #ERRORS AS E2 WHERE E1.LOGMESSAGE = E2.LOGMESSAGE AND E1.SERVERID <> E2.SERVERID ORDER BY OCCURENCES )
upvoted 12 times
...
Ilray
Highly Voted 5 years, 8 months ago
I think В is correct. In A statement "ORDER BY" without DESC, hence TOP (1) returns min value of occurences.
upvoted 8 times
...
Vermonster
Most Recent 4 years, 4 months ago
B is closest
upvoted 1 times
...
Andy7622
4 years, 4 months ago
In A ORDER BY sorts Occurrencies in ascending order so we'll have a log message with the MIN number of occurrencies. In my opinion the closest one is B
upvoted 1 times
...
HA2020
4 years, 6 months ago
The answer does not satisfy the requirement if there is more than one server with the same error message and the same number of occurrences.
upvoted 1 times
...
Guino
5 years, 2 months ago
There is A
upvoted 1 times
...
Jiacheng
5 years, 2 months ago
for answer B, just one thing I want to know, why dont't use '>=' all(...), when using '>', how could 100>100?
upvoted 2 times
HA2020
4 years, 6 months ago
because they want 'distinct' error messages. If you add the equal operand to the comparison and you have more than one server with the same highest number of occurrences, then the result would have the same error message listed for all these servers with highest occurrences..won't be distinct.
upvoted 1 times
...
...
AshleyLiang
5 years, 8 months ago
A repeated question the closest answer should be B.
upvoted 6 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