sql8.0 rank 函数的小知识点
select emp_no,salary,dense_rank() over(order by salary desc)as rank
from salaries
where to_date = '9999-01-01'
order by rank,emp_no;
这样会显示错误:SQL_ERROR_INFO: “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘rank\nfrom salaries\nwhere to_date = ‘9999-01-01’\norder by rank,emp_no’ at line 1”
改正如下
select emp_no,salary,dense_rank() over w as 'rank'
from salaries
where to_date='9999-01-01'
WINDOW w as (order by salary desc)
创建窗口函数才行,也又可能是因为版本原因