title: fetching last 3 rows in ascending order with t-sql?
body: <pre><code>CommentID   Name       Replies                             OrderID
  313         Ed         dlfkndl sdknldgf dlffdg               496
  313         James      sdsflsdf snflsf sfnslf sfnklsdf       499
  313         Jeff       sdsflsdf snflsf sfnslf sfnklsdf       500
  313         Alan       sdsflsdf snflsf sfnslf sfnklsdf       501
  313         William    sdflksnfdlsk sdfknslnf slfnks         503
  </code></pre>
  
  <p>I have a sample table above which is in an ascending order by [OrderID]. I want to fetch the last
  3 rows of the table which is in an ascending order as well which is shown below.</p>
  
  <pre><code>CommentID   Name       Replies                              OrderID
  313         Jeff       sdsflsdf snflsf sfnslf sfnklsdf        500
  313         Alan       sdsflsdf snflsf sfnslf sfnklsdf        501
  313         William    sdflksnfdlsk sdfknslnf slfnks          503
  </code></pre>
  
  <p>What is the exact syntax to do this in T-SQL? Thanks...
  I tried to come up with this but still not not fetching the last 3 rows in an asc order.</p>
  
  <pre><code>SqlCommand cmd = new SqlCommand("SELECT * FROM [RepTab] WHERE [OrderID] &gt; (SELECT MAX([OrderID]) - 3 FROM [RepTab] WHERE [CommentID]='" + Id + "') ", con);
  </code></pre>