I have a query which should return a row number column that starts from 1 regardless of the conditions from the WHERE
statement. The problem is that when I try to access it I am receiving the following error:
Column 'page_rn' cannot be resolved
This is my query:
SELECT t.*,
ROW_NUMBER() OVER () as page_rn
FROM (SELECT row_number() over() AS rn, t.*
FROM transactions t
) t
WHERE page_rn BETWEEN 0 AND 10 AND
date > CAST('2021-03-01' AS DATE)
How can I make the query work with the page_rn
included in the WHERE
statement?
seems like you want to do this:
SELECT t.*
FROM
(
SELECT row_number() over() AS rn,t.*
FROM transactions t
where date > CAST('2021-03-01' AS DATE)
) t
WHERE rn BETWEEN 0 AND 10
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.