The RANK() function in Oracle is used to sort the data group and assign the ranking: assign the same value to the same ranking Sort in the order of increasing value Starting from 1 to assign the ranking If there are duplicate values, the next value The ranking will be skipped
##RANK() function in Oracle
RANK() function is used to rank a group of The data is sorted and rankings assigned. It assigns identical values to the same rank and sorts them in increasing value order.Syntax
<code class="sql">RANK() OVER (PARTITION BY partition_expression ORDER BY order_expression)</code>
Parameters
How it works
RANK() function finds the position of each value within a group and assigns the following ranking:Example
<code class="sql">SELECT id, name, RANK() OVER (PARTITION BY job ORDER BY salary) AS job_rank FROM employees;</code>
name | job_rank | |
---|---|---|
John Doe | 1 | |
Jane Smith | 2 | |
Peter Parker | 1 | |
Mary Jones | 2 | ##5 |
1 |
The above is the detailed content of How to use rank function in oracle. For more information, please follow other related articles on the PHP Chinese website!