随笔 - 1133  文章 - 0 评论 - 19 阅读 - 20万

MYSQL:

复制代码
SELECT  s.emp_no,Y.salary,Y.t_rank
FROM
(SELECT X.salary,CAST((@number := @number+1) AS SIGNED) AS t_rank
FROM
(SELECT DISTINCT salary
FROM salaries
ORDER BY salary DESC) X
JOIN (SELECT @number:=0) AS it) Y
JOIN salaries s
ON Y.salary=s.salary
ORDER BY Y.salary DESC,s.emp_no ASC;
复制代码

 

posted on   Sempron2800+  阅读(105)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示