MySQL是否有一种很好的方式来复制SQL Server功能ROW_NUMBER()?
例如:
SELECT
col1, col2,
ROW_NUMBER() OVER (PARTITION BY col1, col2 ORDER BY col3 DESC) AS intRow
FROM Table1
Run Code Online (Sandbox Code Playgroud)
然后,我可以,例如,添加一个限制intRow为1 的条件,以获得col3每(col1, col2)对最高的单行.
我在MySql中创建了一个视图.但现在我的要求是在该视图中创建一个应该是自动增量的Id列.
我目前的观点是: -
CREATE VIEW pending_assign_report_view AS
select cg.group_name,c.client_name, wt.work_type,p.Minor_worktype, ay.year,aev.emp_name,ep.Date_assigned_on
from employee_project ep,active_employee_view aev, project p, client_group cg, client c,work_type wt,assessment_year ay
where ep.task_status_id=1 and ep.username=aev.username and ep.project_id=p.project_id and p.Year_id=ay.Year_id
and p.Client_group_id=cg.client_group_id and p.Client_id=c.Client_id and p.Work_type_id=wt.Work_type_id
order by cg.group_name,c.client_name, aev.emp_name;
Run Code Online (Sandbox Code Playgroud)
现在我希望Id列作为第一列,本质上应该是auto_increment.我该怎么做?提前致谢.