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
  • 21,969
  • 32
  • 147
  • 289

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,242,037
  • 58
  • 646
  • 786