Oracle over function usage rank () over ([query_partition_clause] order_by_clause) dense_rank () over ([query_partition_clause] order_by_clause) can be grouped by specified fields, sort the result set of the same grouping field. partition by is the grouping field, and order by cannot be used separately because it must be used with the analysis functions rank (), dense_rank (), row_number () and so on. Its Parameter: over (partition by columnname1 order by columnname2) meaning: sort by columname1 by group, or by the value of columnname1 by group. For example, in the employees table, there are two Department records: department_id = 10 and 20 select department_id, rank () over (partition by department_id order by salary) from employees refers to the ranking of salaries in department 10 and in department 20. If it is partition by org_id, It is ranked within the company. For example, grouping the same code but the title is empty, grouping the rate first, and then sorting by row_number () select table1.code, row_number () over (partition by t1.code order by nvl (title, 0) desc) num from table1 where table1.status = 1 order by code: code num ----------------------- -------- 1 420000029 12 420000029 23 420000031 14 420000032 15 420000046 16 420000046 2