title: SQL ROW_NUMBER() issue with paging
body: <p>I use <code>ROW_NUMBER()</code> function to get 50 by 50 items from database table.<br/>
  <code>@From</code> parameter is row from which to start grabbing 50 rows. (First time it is 1 that 51,101,151 etc.)<br/>
  I pass parameter <code>@CityId</code> to stored procedure and if first 60 rows in database are <code>cityId=1</code> and <code>cityId = 2</code> is in row 61 this stored procedure doesn't return result.<br/>
  But if I pass @From parameter 51 than it return me result.
  What I did wrong here?</p>
  
  <pre><code>SELECT  RowConstrainedResult.*
  FROM    ( SELECT    ROW_NUMBER() OVER 
  ( ORDER BY f.ItemCreatedOnDate DESC ) AS RowNum, 
  f.*
  FROM (
  SELECT
        t.ItemIdId,
        t.ItemTypeId,
        t.CreatedOnDate as ItemCreatedOnDate,
        t.CityId as CityId
  FROM   dbo.Items    as t
  ) f) AS RowConstrainedResult
  WHERE   RowNum &gt;= @From
      AND RowNum &lt; @From + 50
      AND CityId = @CityId
  </code></pre>