sqlsql-serverdatabaseselectkeyword

How to select bottom most rows?


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

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...)?


Solution

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