TOP:
The TOP option in T-SQL feature allows us to limit the number or percentage of rows that the query returns.
It relies on two elements as part of its specifications.
1. Number or percent of rows to return.
2. The ordering of result
We can Use TOP option with PERCENT keyword , in which SQL Server calculates the number of rows to return based on percentage of the number of qualifying rows rounded up.
When TOP is specified with ORDER BY Clause , the ORDER BY clause serves a dual purpose in the Query.
One Purpose is to define presentation ordering for the rows in the query result , Another purpose is to define which rows to filter for TOP.
OFFSET-FETCH:
The OFFSET-FETCH filter is considered part of ORDER BY clause which normally serves a presentation ordering purpose.
The Query that Uses OFFSET-FETCH must have an ORDER BY Clause.
By Using OFFSET Clause , we can indicate how many rows to skip and by using FETCH clause we can indicate how many rows to filter after the skipped rows.
FETCH Clause is not supported without an OFFSET Clause .
OFFSET Without FETCH is allowed, in such scenarios the query skips the indicated number of rows and returns all remaining rows in the result.
On this page of the site you can watch the video online TOP | OFFSET-FETCH | SQL Server | SQL Tutorial with a duration of hours minute second in good quality, which was uploaded by the user Uday Bhoyar 20 November 2022, share the link with friends and acquaintances, this video has already been watched 538 times on youtube and it was liked by 13 viewers. Enjoy your viewing!