0

I would like to know if there is a keyword similar to fetch first provided here for selecting the last rows?

I know something similar can be done by changing the sorting from say ascending to descending and use that, but I want to avoid that for now.

Jackie
  • 19,725
  • 31
  • 126
  • 253

1 Answers1

1

There is no fetch last.

One solution is to reverse the sort order . . . but that reverses the results. So, two sorts are necessary:

select t.*
from (select t.*
      from t
      order by . . . desc
      offset 0 fetch first 10 rows only
     ) t
order by . . . asc;
Gordon Linoff
  • 1,198,228
  • 53
  • 572
  • 709