Want Row Number on Group of column in MY SQL?

后端 未结 5 1877
不思量自难忘°
不思量自难忘° 2020-12-20 19:34

I have one table in MYSQL It has data like

Id Name 
1  test
1  test
1  test123
2  test222
3  test333

I want the data like

Id Name     RowN         


        
5条回答
  •  醉话见心
    2020-12-20 20:21

    Oracle and MSSQL would support

    SELECT Id, Name, row_number() OVER(partition by Id, Name order by Id) AS RowNum FROM table
    

    (answer doesn't help the OP who is on MySQL, but added for completeness)

提交回复
热议问题