T-SQL reference › OFFSET FETCH
OFFSET FETCH in SQL Server: paging
OFFSET FETCH skips N rows then takes M. It is paging. It needs ORDER BY. For “the five biggest” you still want TOP.
Page of customers
SELECT customer_id, first_name, last_name, email
FROM Customers
ORDER BY last_name, customer_id
OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY;
Page 3 if the page size is 10. Without a stable ORDER BY (include the key), page 2 can overlap page 1 after an insert.
Try it on Harbour & Co
Sandra Okafor (Managing Director) needs this now: “Board pack: our 5 biggest orders ever. Order, customer, amount.” Write the query, run it, send the results. On the paid plan.
Take the ticket →Learn it on a real ticket
Monday is free on WorkSQL. A colleague’s ticket lands, you write the T-SQL, we mark it. No videos. Five minutes.
Clock in free See Monday’s tickets