Difference between revisions of "RANK"
Jump to navigation
Jump to search
(Created page with "<table align='right' border='1'> <caption>Compatibility</caption> <tr><th colspan='3'>RANK() OVER (ORDER BY f DESC)</th></tr> <tr><td align='center'>'''Engine'''</td><td align...") |
|||
Line 19: | Line 19: | ||
<source lang='sql' class='def'> | <source lang='sql' class='def'> | ||
SELECT name,population, | SELECT name,population, | ||
RANK() OVER (ORDER BY population DESC) AS r | RANK() OVER (ORDER BY population DESC) | ||
AS r | |||
FROM bbc WHERE population>180000000 | FROM bbc WHERE population>180000000 | ||
ORDER BY name | ORDER BY name |
Revision as of 10:52, 13 July 2012
RANK() OVER (ORDER BY f DESC) | ||
---|---|---|
Engine | OK | Alternative |
ingres | No | |
mysql | No | |
oracle | Yes | |
postgres | No | |
sqlserver | Yes |
RANK
RANK() OVER (ORDER BY f DESC) returns the rank position relative to the expression f.
RANK() OVER (ORDER BY f DESC)
In this example we show the ranking, by population of those countries with a population of over 180 million.
SELECT name,population,
RANK() OVER (ORDER BY population DESC)
AS r
FROM bbc WHERE population>180000000
ORDER BY name
See also