时间:2021-07-01 10:21:17 帮助过:5人阅读
select (@i:=@i+1) i,emp.* from emp,(select @i:=0) it
按部门分组并按薪资总和从大到小排序求薪资总和第二高的部门名称和薪资总和:select c.ename,c.s from (select (@i:=@i+1) i,e.* from (SELECT ename,SUM(sal) s FROM emp GROUP BY deptno ORDER BY s desc) e,(select @i:=0) it) c where c.i=2
mysql中给查询出的结果集添加自增序号
标签:sel name HERE bsp from 添加 自增 i+1 mysql