title: SQL syntax error: Multi-part identifier could not be bound for ROW_NUMBER()
body: <p>Need to solve this</p>
  <p>This is for a REST API and i need count on each row so that i can use it for Pagination purposes.</p>
  <pre><code>SELECT *
  FROM   (SELECT ROW_NUMBER()
                   OVER (
                     ORDER BY sc.LEGACY_PARTY_ID) AS rownum,
                 *
          FROM   (SELECT *,
                         ROW_NUMBER()
                           OVER (
                             ORDER BY sc.LEGACY_PARTY_ID) AS rownuminner
                  FROM   (SELECT *
                          FROM   (SELECT sc.legacy_party_id,
                                         sc.practice,
                                         sr.risk_level
                                  FROM   dbo.supplier sc
                                  INNER JOIN dbo.risk sr
                                    ON sc.LEGACY_PARTY_ID = sr.LEGACY_PARTY_ID)AS z) AS a)AS c
          WHERE  rownuminner &lt;= ?)c
  WHERE  rownum &gt; ?; 
  </code></pre>
  <p>Need elements of a table with row_number for each row but getting this error:</p>
  <blockquote>
  <p>Msg 4104, Level 16, State 1, Line 21<br />
  The multi-part identifier &quot;sc.LEGACY_PARTY_ID&quot; could not be bound.</p>
  <p>Msg 4104, Level 16, State 1, Line 20<br />
  The multi-part identifier &quot;sc.LEGACY_PARTY_ID&quot; could not be bound.</p>
  </blockquote>