SQL Server rownumbering and filtered results

后端 未结 3 677
死守一世寂寞
死守一世寂寞 2021-01-14 03:21

I have an application in which I need to display \"pages\" of data in a list. The basic idea is fairly common. The display shows a list of items and at the bottom of the dis

3条回答
  •  北海茫月
    2021-01-14 03:36

    Something like this should do...

    SELECT * FROM (
    SELECT  *, ROW_NUMBER() OVER (ORDER BY LastName, FirstName, DoB) AS __RN
    FROM    CampaignParticipants
    WHERE   LastName LIKE 'R%') innerData WHERE __RN BETWEEN 1 and 100
    

    However, you should be using the column names, not '*'. I don't know what your tables look like so I can't fill that in for you.

提交回复
热议问题