select (@i:[email protected] 1) i,emp.* from emp,(select @i:=0) it
按部门分组并按薪资总和从大到小排序求薪资总和第二高的部门名称和薪资总和:select c.ename,c.s from (select (@i:[email protected] 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