与oracle的 rownumber() over(partition by xxx order by xxx )语句类似,即:对表分组后排序
创建测试emp表
DROP TABLE IF EXISTS emp;
CREATE TABLE emp (
empno decimal(4,0) NOT NULL,
ename varchar(10) DEFAULT NULL,
job varchar(9) DEFAULT NULL,
mgr decimal(4,0) DEFAULT NULL,
hiredate datetime DEFAULT NULL,
sal decimal(7,2) DEFAULT NULL,
comm decimal(7,2) DEFAULT NULL,
deptno decimal(2,0) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of emp
-- ----------------------------
INSERT INTO emp VALUES ('7369', 'SMITH', 'CLERK', '7902', '19