Is there any way to efficiently perform the equivalent of DENSE_RANK in MongoDB? SQL Server and Oracle both have DENSE_RANK functions. Is there a way to do something similar in MongoDB without having to resort to MapReduce? In other words, suppose you have a T-SQL select clause like this:

SELECT DENSE_RANK() OVER(ORDER BY SomeField DESC) SomeRank


What is the best way to do the same thing in MongoDB?

(Note: This is a repost of the MongoDB question over here. I'm hoping to get more feedback from DBAs...)
MongoDB doesn't have any concept of ranking.  The closest I could find comes from here:

Here's some sample data:
 &gt; db.scoreboard.find()`
 { &quot;_id&quot; : ObjectId(&quot;4d99f71450f0ae2165669ea9&quot;), &quot;user&quot; : &quot;dave&quot;, &quot;score&quot; : 4 }
 { &quot;_id&quot; : ObjectId(&quot;4d99f71b50f0ae2165669eaa&quot;), &quot;user&quot; : &quot;steve&quot;, &quot;score&quot; : 5 }`
 { &quot;_id&quot; : ObjectId(&quot;4d99f72350f0ae2165669eab&quot;), &quot;user&quot; : &quot;tom&quot;, &quot;score&quot; : 3 }

First, find the score of the user &quot;dave&quot;:
 db.scoreboard.find({ user : &quot;dave&quot; }, { score : 1 }) { &quot;_id&quot; : ObjectId(&quot;4d99f71450f0ae2165669ea9&quot;), &quot;score&quot; : 4 }

Then, count how many users have a higher score:
 db.scoreboard.find({ score : { $gt : 4 }}).count() 
 1

Since there is 1 higher score, dave's rank is 2 (just add 1 to the
count of higher scores to get the rank).

Obviously, this is far from ideal.  However, MongoDB simply does not have any type of functionality for this since it's simply not designed for this type of querying.