SELECT *, Row_Number() OVER (partition by deptid ORDER BY salary desc) rank FROM employee
Row_Number()显示行号,加上partition by还能分组排序显示行号。
就这么一句sql,每次忘记这个Row_Number()回头一看就什么都明白了。
2024-03-11 21:44:25
SELECT *, Row_Number() OVER (partition by deptid ORDER BY salary desc) rank FROM employee
Row_Number()显示行号,加上partition by还能分组排序显示行号。
就这么一句sql,每次忘记这个Row_Number()回头一看就什么都明白了。