Which ranking function should you use?

You work as a database developer at ABC.com. ABC.com has a SQL Server 2012 database
named SalesDB that has a table named WeeklySales. The WeeklySales table records the sales
amount for each of ABC.com’s 20 sales representitives.
You need to write a Transact-SQL query that ranks the sales representatives by the average sales
amount for the past year. You want the sales representatives with the same average sales amount
to have the same rank with the subsequent rank being skipped.
Which ranking function should you use?

You work as a database developer at ABC.com. ABC.com has a SQL Server 2012 database
named SalesDB that has a table named WeeklySales. The WeeklySales table records the sales
amount for each of ABC.com’s 20 sales representitives.
You need to write a Transact-SQL query that ranks the sales representatives by the average sales
amount for the past year. You want the sales representatives with the same average sales amount
to have the same rank with the subsequent rank being skipped.
Which ranking function should you use?

A.
The RANK( ) OVER function.

B.
The NTILE( ) OVER function

C.
The DENSE_RANK( ) OVER function

D.
The ROW_NUMBER( ) OVER function

E.
The FORMAT function.

Explanation:

Ref: http://msdn.microsoft.com/en-us/library/ms189798.aspx



Leave a Reply 3

Your email address will not be published. Required fields are marked *


Fariba

Fariba

I saw this question in many sites, and the answered was written Dense_rank.
but I think because of this ” with the subsequent rank being skipped” it should be Rank()

would you please tell me which of them is true?

Nuno Filipe

Nuno Filipe

True Saw that same question on internet and the answer was DENSE_RANK.
For me is Rank() too and not DENSE_RANK() the answer for that specific question.
RANK() Example = 1233557888
DENSE_RANK() Example = 12223344445677

“with the subsequent rank being skipped” is RANK()

lewis

lewis

thanks for your clarification