DBA > Job Interview Questions > Microsoft SQL Server FAQs

What T-SQL function can achieve this?

More DBA job interview questions and answers at http://dba.fyicenter.com/Interview-Questions/

(Continued from previous question...)

What T-SQL function can achieve this?

You have to create some T-SQL that produces an order of players in a golf tournament. Players who finish on the same number of strokes have to be given the same finishing place denoting that they will have an equal prize amount. What T-SQL function can achieve this?


Answer
RANK alongside the OVER function where the OVER function uses the players number of strokes taken

Explanation
The rank function will return the rank of the row in the result set. Ties will receive the same rank. The OVER clause will separate out the ranking into partitions and use those for calculating the proper placement of the golfers.

(Continued on next question...)

Other Job Interview Questions