行号分区mysql工作台

时间:2018-06-28 22:51:10

标签: mysql-workbench

这有什么问题

select 
ID
,SYSCODE
,LID
,ROW_NUMBER() OVER(PARTITION BY ID ORDER BY SYSCODE, LID) AS row_num
 from prod_sys.P_ENTERPRISE

它可以在Management Studio中工作,但不能在mysql工作台中工作

1 个答案:

答案 0 :(得分:0)

MYSQL中没有ROW_NUMBER(),请按如下所示重写查询。

select 
ID
,SYSCODE
,LID
,@row_num := @row_num + 1 as Row_number
 from prod_sys.P_ENTERPRISE join (SELECT @row_num := 0) a;