exam questions

Exam 70-461 All Questions

View all questions & answers for the 70-461 exam

Exam 70-461 topic 1 question 71 discussion

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

Note: This question is part of a series of questions that use the same set of answer choices. An answer choice may be correct for more than one question in the series.
You create a table that has the StudentCode, SubjectCode, and Marks columns to record mid-year marks for students. The table has marks obtained by 50 students for various subjects.
You need to ensure that the following requirements are met:
✑ Students must be ranked based on their average marks.
✑ If one or more students have the same average, the same rank must be given to these students.
✑ Consecutive ranks must be skipped when the same rank is assigned.
Which Transact-SQL query should you use?

  • A. SELECT StudentCode as Code, RANK() OVER(ORDER BY AVG (Marks) DESC) AS Value FROM StudentMarks GROUP BY StudentCode
  • B. SELECT Id, Name, Marks, DENSE_RANK() OVER(ORDER BY Marks DESC) AS Rank FROM StudentMarks
  • C. SELECT StudentCode as Code, DENSE_RANK() OVER(ORDER BY AVG (Marks) DESC) AS Value FROM StudentMarks GROUP BY StudentCode
  • D. SELECT StudentCode as Code, NTILE(2) OVER(ORDER BY AVG (Marks) DESC) AS Value FROM StudentMarks GROUP BY StudentCode
  • E. SELECT StudentCode AS Code,Marks AS Value FROM ( SELECT StudentCode, Marks AS Marks, RANK() OVER(PARTITION BY SubjectCode ORDER BY Marks ASC) AS Rank FROM StudentMarks) tmp WHERE Rank = 1
  • F. SELECT StudentCode AS Code,Marks AS Value FROM ( SELECT StudentCode, Marks AS Marks, RANK() OVER(PARTITION BY SubjectCode ORDER BY Marks DESC) AS Rank FROM StudentMarks) tmp WHERE Rank = 1
  • G. SELECT StudentCode AS Code,Marks AS Value FROM ( SELECT StudentCode, Marks AS Marks, RANK() OVER(PARTITION BY StudentCode ORDER BY Marks ASC) AS Rank FROM StudentMarks) tmp WHERE Rank = 1
  • H. SELECT StudentCode AS Code,Marks AS Value FROM ( SELECT StudentCode, Marks AS Marks, RANK () OVER(PARTITION BY StudentCode ORDER BY Marks DESC) AS Rank FROM StudentMarks) tmp WHERE Rank = 1
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
Reference:
http://msdn.microsoft.com/en-us/library/ms189798.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
LisasGenesis
4 years, 5 months ago
Rank functions include: - Row_Number(): to get a unique sequential number for each row. It gives the rank one for the first row and then increments the value by one for each row. - Rank(): used to specify rank for each row in the result set. - Dense_Rank(): to specify a unique rank number within the partition as per the specified column value. It is similar to the Rank function with a small difference. If we have duplicate values, SQL assigns different ranks to those rows as well. Ideally, you should get the same rank for duplicate values. - Ntile(): to distribute the number of rows in the specified (N) number of groups. Each row group gets its rank as per the specified condition. In the SQL Rank functions, we use the OVER() clause to define a set of rows in the result set. You can also use SQL Partition by clause to define a subset of data in a partition.
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 ...