How do I use ROW_NUMBER()?

前端 未结 13 2457
青春惊慌失措
青春惊慌失措 2020-11-28 02:35

I want to use the ROW_NUMBER() to get...

  1. To get the max(ROW_NUMBER()) --> Or i guess this would also be the count of all rows
13条回答
  •  佛祖请我去吃肉
    2020-11-28 03:32

    You can use this for get first record where has clause

    SELECT TOP(1) * , ROW_NUMBER() OVER(ORDER BY UserId) AS rownum 
    FROM     Users 
    WHERE    UserName = 'Joe'
    ORDER BY rownum ASC
    

提交回复
热议问题