sql query distinct with Row_Number

后端 未结 8 1124
死守一世寂寞
死守一世寂寞 2020-11-28 09:00

I am fighting with the distinct keyword in sql. I just want to display all row numbers of unique (distinct) values in a column & so I tried:

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 09:51

    This can be done very simple, you were pretty close already

    SELECT distinct id, DENSE_RANK() OVER (ORDER BY  id) AS RowNum
    FROM table
    WHERE fid = 64
    

提交回复
热议问题