Home  >  Article  >  Database  >  MYSQL-实现ORACLE- row_number() over(partition by ) 分组排序_MySQL

MYSQL-实现ORACLE- row_number() over(partition by ) 分组排序_MySQL

WBOY
WBOYOriginal
2016-06-01 13:48:281095browse

bitsCN.com

今天看了篇帖子,被几个地方转载,但是性能不太好,因为不能评论,所以把优化思路写在这里。

1.确定需求: 根据部门来分组,显示各员工在部门里按薪水排名名次.

2.来创建实例数据:

drop table if exists heyf_t10;

create table heyf_t10 (empid int ,deptid int ,salary decimal(10,2) );bitsCN.com
Statement:
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