RANK

Returns the rank of a value in a group of values. The rank is one plus the number of rows preceding the row that are not peer with the row. Unlike DENSE_RANK, values that are the same in the ordering will produce gaps in the sequence.

No Parameters

Returns: decimal

Example

query:

SELECT playerid, HR, RANK() OVER ( ORDER BY HR DESC)
  FROM batting
 WHERE yearId = 2000
 ORDER BY HR DESC, playerid

result:

playerid HR rank
sosasa01 50 1
bondsba01 49 2
bagweje01 47 3
glaustr01 47 3
guerrvl01 44 5
hidalri01 44 5
giambja01 43 7
sheffga01 43 7
thomafr04 43 7
edmonji01 42 10
heltoto01 42 10
batisto01 41 12
delgaca01 41 12
rodrial01 41 12
griffke02 40 15
palmera01 39 16
piazzmi01 38 17
ramirma02 38 17
martied01 37 19
thomeji01 37 19