I am trying to create a query that I can then use for a paging system here is the query as it stands
SELECT
SLCustomerAccountID,
CustomerAccountNumber,
CustomerAccountName,
(MainTelephoneAreaCode + MainTelephoneSubscriberNumber) AS PhoneNumber,
Row_Number() over (order by CustomerAccountName) as RowIndex
FROM
SLCustomerAccount
WHERE
CustomerAccountName LIKE '%green%'
AND RowIndex BETWEEN 10 AND 30
ORDER BY
CustomerAccountName
This query errors with
Invalid column name 'RowIndex'.
because I am trying to use the alias, but I am not sure of the correct way to set this so I can use the data that is in the column RowIndex
Here is what the query returns without the where clause
ID1 ID2 NAME Number Row number
__________________________________________
| 12374927| 00010014|Some name| ******| 1|
| 51744 | 6631 |Same name| ******| 2|