I know how to set "top n", but if number of top depens on select result, I don't know how to set number of top.
for example(This works well):
select top 50 * from tbl order by id
I want to set as follows
select top (select count(*) from tbl where id < 50) * from tbl order by id
but this SQL is invalid.
Is there any solutions?