In Sql Server 2014 ORDER BY clause with OFFSET FETCH NEXT returns weird results

前端 未结 2 1480
我寻月下人不归
我寻月下人不归 2021-01-12 21:34

I am currently using Sql Server 2014 Professional and the current version is (12.0.4100). I have a View and I am trying to SELECT 10 rows with specific offset.
My View i

2条回答
  •  孤街浪徒
    2021-01-12 22:32

    your order by should be unique,otherwise you will get indeterministic results(in your case ,begin time is not unique and your are not guarnteed to get same results every time).try changing your query to below to make it unique..

    SELECT * FROM View_Name ORDER BY duration OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY
    

    Further to add ,your first query (select * from view) result set is not guaranteed to be accurate every time unless you have an outer order by .

提交回复
热议问题