I wish to fetch all rows from table after the nth Position as i given offset value my table like
id | Value
1 | A |
2 | B |
3 | C |
4 | D |
5 | E |
...
N | R |
I wants the 3rd row Data to Nth Rows How to i Retrive
I wish to fetch all rows from table after the nth Position as i given offset value my table like
id | Value
1 | A |
2 | B |
3 | C |
4 | D |
5 | E |
...
N | R |
I wants the 3rd row Data to Nth Rows How to i Retrive
Disclaimer, the oldest version I could test was 5.6
select t1.id, t1.val
from t t1
left join (
select t2.id from t t2 order by id limit 2
) x
on t1.id = x.id
where x.id is null;
For 8.0, a window function is the most natural choice
select id, val from (
select id, val
, row_number() over (order by id) as rn
from t
) as x
where rn > 2
As ypercubeᵀᴹ pointed out in a comment, LIMIT in combination with OFFSET can also be used. For a trivial case with only one partition, it is likely the most efficient solution:
SELECT t1.id, t1.val
FROM t t1
LIMIT 1000000000000 OFFSET 2