SELECT * FROM (
SELECT ROW_NUMBER() OVER (ORDER BY ProductID) AS rn, p.*
FROM(
SELECT * FROM products
) p) p2
WHERE rn BETWEEN 0 AND 10
ORDER BY rn
I don't want the above query to return the rn column.
SELECT * FROM (
SELECT ROW_NUMBER() OVER (ORDER BY ProductID) AS rn, p.*
FROM(
SELECT * FROM products
) p) p2
WHERE rn BETWEEN 0 AND 10
ORDER BY rn
I don't want the above query to return the rn column.
As of your sample query you are selecting top 10 records ordered by ProductID. If it is true then the same results can be achieved by the following:
select * from
(select * from products order by ProductID)
where rownum <= 10
If it is not the results you are expecting then please correct your query (maybe add "PARTITION BY").