Home > Database > Mysql Tutorial > Oracle Over的使用

Oracle Over的使用

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:06:39
Original
1035 people have browsed it

RANK ( ) OVER ( [query_partition_clause] order_by_clause ) DENSE_RANK ( ) OVER ( [query_partition_clause] order_by_claus

RANK ( ) OVER ( [query_partition_clause] order_by_clause )

DENSE_RANK ( ) OVER ( [query_partition_clause] order_by_clause )

可实现按指定的字段分组排序,对于相同分组字段的结果集进行排序,

其中PARTITION BY 为分组字段,ORDER BY 指定排序字段

over不能单独使用,要和分析函数:rank(),dense_rank(),row_number()等一起使用。

其参数:over(partition by columnname1 order by columnname2)

含义:按columname1指定的字段进行分组排序,或者说按字段columnname1的值进行分组排序。

例如:employees表中,有两个部门的记录:department_id =10和20

select department_id,rank() over(partition by department_id order by salary) from employees就是指在部门10中进行薪水的排名,在部门20中进行薪水排名。如果是partition by org_id,,则是在整个公司内进行排名。

linux

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template