我需要找出客户的排名.在这里,我为我的要求添加了相应的ANSI标准SQL查询.请帮我转换为MySQL.
SELECT RANK() OVER (PARTITION BY Gender ORDER BY Age) AS [Partition by Gender],
FirstName,
Age,
Gender
FROM Person
Run Code Online (Sandbox Code Playgroud)
有没有找到MySQL排名的函数?
是否有类似于的命令:
2nd highest salary from tbl_salary 要么
4th highest salary from tbl_salary ?
我见过:
select salary
from tbl_salary t
where &n = (
select count(salary)
from(
select distinct salary
from tbl_salary
)where t.salary<=salary
);
Run Code Online (Sandbox Code Playgroud)
它是如何工作的?
有没有其他简单的方法来获得结果?