select top 10 * from (select top 40 * from tb desc) asc
select top 40 * from A where id not in(select top 30 id from A)
which of above 2 is more efficient? why?
in sql 2005+ ,you should use
SELECT col1, col2
FROM (
SELECT col1, col2, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum
FROM MyTable
) AS MyDerivedTable
WHERE MyDerivedTable.RowNum BETWEEN @startRow AND @endRow
No comments:
Post a Comment