Need to solve this

This is for a REST API and i need count on each row so that i can use it for Pagination purposes.

```
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 <= ?)c
WHERE  rownum > ?; 

```

Need elements of a table with row\_number for each row but getting this error:

> 
> Msg 4104, Level 16, State 1, Line 21  
> 
> The multi-part identifier "sc.LEGACY\_PARTY\_ID" could not be bound.
> 
> 
> Msg 4104, Level 16, State 1, Line 20  
> 
> The multi-part identifier "sc.LEGACY\_PARTY\_ID" could not be bound.
> 
> 
>