title: SQL Server: CTE, how to get last row number
body: <p>I have a CTE like this:</p>
  
  <pre><code>;WITH Lastdt AS
  (
      SELECT database_name, backup_finish_date,
      ROW_NUMBER() OVER (PARTITION BY database_name ORDER BY backup_finish_date, database_name) AS 'RowNumber'
      FROM bckHist
  ) 
  SELECT database_name, backup_finish_date
  FROM Lastdt
  WHERE RowNumber = '7'
  </code></pre>
  
  <p>How can I get last row with highest number from the query (replace hardcoded 7)?</p>