can anybody provide me cost effective query for my title question,also im not expecting cursors in this context. thanks in advance.
do you mean a random set of 6,7 or 8 rows from your 10?
select top 6 column from table
or rows 6,7 and 8 from the original 10? (you need to specify what ordering should be used)
---get the bottom 3 (6,7,8) from the top 8
select top 3 column
from
(select top 8 column from table order by column asc) tablealias
order by column desc
or if you are using SQL2005 and above, you can use row_number()
(again need to define an order)
select column
from (
select row_number()over (order by column) as rownum, column
from table
) alias
where rownum in (6,7,8)
or use a common table expression (cte)
;with cte (rownum,column) as
(
select row_number()over (order by column) as rownum, column
from table
)
select column from cte
where rownum in (6,7,8)
No one has followed this question yet.