WHERE rk < 4 二、ROW_NUMBER为例: 1、求连续出现的数字: SELECT DISTINCT(num) AS ConsecutiveNums FROM ( SELECT id,num, (ROW_NUMBER() OVER(ORDER BY id) - ROW_NUMBER() OVER(PARTITION BY num ORDER BY id)) AS ranksub FROM Logs ) AS sub GROUP BY num,ranksub HAVING count(*)>...
就是dense_rank在group by 后的应用 select id,NAME,grade_num from (select user_id,sum(grade_num) grade_num,dense_rank() over (order by sum(grade_num) desc) rk from grade_info group by user_id) tt join user u on tt.user_id=u.id where rk=1 order by id;点...