I am using sybase database.
I have to select every nth row from my table selfjoin(id,salary);
I use
select top 1 * from (select top 4 * from selfjoin order by id desc) order by id I get an error though.
An ORDER BY clause is not allowed in a derived table. The below sql also results in an error
select id from selfjoin order by id asc limit 2 --error :-`Incorrect syntax near 'limit'` Also the below sql throws an error.
SELECT ROW_NUMBER() OVER (ORDER BY id ASC) AS rownumber,salary from selfjoin; --error :- `Incorrect syntax near the keyword 'OVER'.` I also read this link but no query is working. I also checked for this page,but didn't get correct result.
Change in Question:- salary in table is in ascending order. i.e., nth row is to be found according to ascending order of salary.