如何选择最底部的行?

2021-12-19 00:00:00 sql database select keyword sql-server

我可以做 SELECT TOP (200) ...但为什么不做 BOTTOM (200)?

I can do SELECT TOP (200) ... but why not BOTTOM (200)?

不要进入哲学,我的意思是,我怎么能做相当于 TOP (200) 的事情,但反过来(从底部开始,就像你期望 BOTTOM 做的那样......)?

Well not to get into philosophy what I mean is, how can I do the equivalent of TOP (200) but in reverse (from the bottom, like you'd expect BOTTOM to do...)?

推荐答案

SELECT
    columns
FROM
(
     SELECT TOP 200
          columns
     FROM
          My_Table
     ORDER BY
          a_column DESC
) SQ
ORDER BY
     a_column ASC

相关文章