🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › language-elements › fetch-transact-sql
FETCH (Transact-SQL) - SQL Server | Microsoft Learn
November 18, 2025 - USE AdventureWorks2022; GO DECLARE contact_cursor CURSOR FOR SELECT LastName FROM Person.Person WHERE LastName LIKE 'B%' ORDER BY LastName; OPEN contact_cursor; -- Perform the first fetch.
🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-top-limit-fetch-first-clause
SQL TOP, LIMIT, FETCH FIRST Clause - GeeksforGeeks
Let’s understand this using an example of SQL SELECT TOP statement. We will use the following table for this example: In this example, we will fetch the top 4 rows from the table. ... The query retrieves the first 4 rows from the Employee table.
Published   November 10, 2025
Discussions

sql - What is the difference between fetch Next and fetch First in the Order By [...] OFFSET [..] FETCH [...] clause? - Stack Overflow
CopySELECT * FROM Foo ORDER BY ID OFFSET 5 ROWS FETCH FIRST 5 ROWS ONLY; -- Does this mean rows 6 to 10, or 1 to 5? ... CopySELECT * FROM Foo ORDER BY ID OFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY; -- Now it's clear! SqlFiddle example here. More on stackoverflow.com
🌐 stackoverflow.com
Why sqlalchemy fetchall() when it called second time it will return a empty list ?
Because the result you get isn't the actual data, it's a cursor that the database then uses to generate results as you loop over it. More on reddit.com
🌐 r/learnpython
5
6
February 19, 2021
Dbeaver top results
This has nothing to do with Dbeaver you need to use the syntax that is valid for the DBMS you are connecting to. In standard ANSI SQL this would be select * from the_table fetch first 50 rows only; This is e.g. supported by Postgres, Oracle and DB2. SQL Server uses SELECT TOP n .. FROM and MySQL uses LIMIT after the FROM More on reddit.com
🌐 r/SQL
15
13
January 21, 2020
What's the most efficient way to get the last row from a table?
How do you define "last row"? More on reddit.com
🌐 r/SQLServer
38
7
September 3, 2019
People also ask

Q1. How to select the first 5 rows in SQL?
To select the first 5 rows in SQL, we have to run the SQL query: SELECT * FROM table_name LIMIT 5;
🌐
intellipaat.com
intellipaat.com › home › blog › sql top, limit, fetch first clause
SQL TOP, LIMIT, FETCH FIRST Clause - Intellipaat
Q3. What is ORDER BY in SQL?
SQL Order By is used to sort the data in ascending or descending order.
🌐
intellipaat.com
intellipaat.com › home › blog › sql top, limit, fetch first clause
SQL TOP, LIMIT, FETCH FIRST Clause - Intellipaat
Q4. How to remove duplicates in SQL?
To remove duplicates in SQL, we can use the DISTINCT keyword in our SELECT statement.
🌐
intellipaat.com
intellipaat.com › home › blog › sql top, limit, fetch first clause
SQL TOP, LIMIT, FETCH FIRST Clause - Intellipaat
🌐
W3Schools
w3schools.com › sql › sql_top.asp
SQL SELECT TOP, LIMIT and FETCH FIRST
The following SQL selects the first ... MySQL: SELECT * FROM Customers WHERE Country = 'Germany' LIMIT 3; Try it Yourself » · The following SQL shows the equivalent example for Oracle: SELECT * FROM Customers WHERE Country = 'Germany' FETCH FIRST 3 ROWS ONLY...
🌐
Programiz
programiz.com › sql › limit-top-fetch-first
SQL SELECT LIMIT, TOP, FETCH FIRST (With Examples)
Let's look at an example. SELECT TOP 2 first_name, last_name FROM Customers; Here, the SQL command selects first_name and last_name of the first 2 rows. We can also use * with TOP to select all columns. ... Here, the SQL command selects the first 2 rows from the table.
🌐
DbSchema
dbschema.com › blog › tutorials › sql top, limit, fetch first, and rownum explained | dbschema
SQL TOP, LIMIT, FETCH FIRST, and ROWNUM Explained | DbSchema
August 25, 2023 - SELECT TOP number|percent columns FROM table WHERE condition; Let's retrieve the top 3 students from the 'Students' table. ... In the above query, the TOP clause fetches the first three records from the Students table.
🌐
Actian
docs.actian.com › ingres › 10s › SQLRef › FETCH_FIRST_Clause_and_OFFSET_Clause.htm
FETCH FIRST Clause and OFFSET Clause
The OFFSET and FETCH FIRST clauses can be used only once per query, and cannot be used in unions or view definitions. They cannot be used in subselects, except a subselect in a CREATE TABLE statement or an INSERT statement. The FETCH FIRST clause cannot be used in the same SELECT statement as SELECT FIRST rowcount.
🌐
Microsoft Learn
learn.microsoft.com › en-us › previous-versions › sql › sql-server-2012 › ms180152(v=sql.110)
FETCH (Transact-SQL) | Microsoft Learn
USE AdventureWorks2012; GO DECLARE contact_cursor CURSOR FOR SELECT LastName FROM Person.Person WHERE LastName LIKE 'B%' ORDER BY LastName; OPEN contact_cursor; -- Perform the first fetch.
Find elsewhere
🌐
Oracle Tutorial
oracletutorial.com › home › oracle basics › oracle fetch clause
Oracle FETCH
April 26, 2025 - For semantic clarity purposes, you can use the keyword ROW instead of ROWS, FIRST instead of NEXT. For example, the following clauses behave the same: FETCH NEXT 1 ROWS FETCH FIRST 1 ROWCode language: SQL (Structured Query Language) (sql)
🌐
SQL Tutorial
sqltutorial.org › home › sql fetch
SQL FETCH
February 8, 2025 - first_name | salary ------------+---------- Steven | 24000.00 Lex | 17000.00 Neena | 17000.00 John | 14000.00 Karen | 13500.00Code language: SQL (Structured Query Language) (sql) ...
🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-select-first
SQL SELECT FIRST - GeeksforGeeks
July 23, 2025 - SELECT FIRST (Name) AS First_name FROM Stationary; We can use the SELECT FIRST clause in conjunction with the ORDER BY clause to sort the records before fetching the first record.
🌐
Reintech
reintech.io › blog › sql-fetch-statement-comprehensive-tutorial
SQL 'FETCH' Statement: A Comprehensive Tutorial | Reintech media
February 19, 2026 - Introduced in SQL:2008 as part of the standard, it provides a cleaner, more portable alternative to vendor-specific solutions like MySQL's LIMIT or SQL Server's TOP. ... SELECT column1, column2, ... FROM table_name ORDER BY column1, column2, ... ASC|DESC OFFSET n ROWS FETCH FIRST m ROWS ONLY; ... Let's start with a straightforward example.
🌐
Tech Agilist
techagilist.com › home › blog › fetch first n row only and optimize for n rows
FETCH FIRST n ROW ONLY and OPTIMIZE FOR n ROWS - Tech Agilist
December 26, 2023 - If OPTIMIZE FOR n ROWS is not specified, n in FETCH FIRST n ROWS ONLY is used as OPTIMIZE FOR n ROWS for access path selection. If OPTIMIZE FOR x ROWS is coded and x is not equal to n, the smaller value is used, for example:
🌐
DB Vis
dbvis.com › thetable › sql-fetch-retrieving-data-in-database-cursors
SQL FETCH: Retrieving Data In Database Cursors
September 24, 2024 - Here is what a SQL FETCH sample statement looks like in PostgreSQL: ... 1 BEGIN WORK; 2 3 -- define a cursor 4 DECLARE movie_cursor SCROLL CURSOR FOR 5 SELECT * FROM movies; 6 7 -- fetch the first 5 rows in the cursor 8 FETCH FORWARD 5 FROM ...
🌐
Use The Index, Luke
use-the-index-luke.com › sql › partial-results › top-n-queries
Top-N queries: fetch only the first N rows
PostgreSQL supports the fetch first extension since version 8.4. The previously used limit clause still works as shown in the MySQL example. SELECT * FROM sales ORDER BY sale_date DESC FETCH FIRST 10 ROWS ONLY ... SQL Server provides the top ...
🌐
IBM
ibm.com › docs › en › db2-for-zos › 12.0.0
Retrieving a single row of data into host variables - IBM Documentation
January 7, 2026 - You can use the FETCH FIRST 1 ROW ONLY clause in a SELECT statement to ensure that only one row is returned. This action prevents undefined and unpredictable data from being returned when you specify the INTO clause of the SELECT statement.
🌐
IBM
ibm.com › docs › en › db2-for-zos › 11
fetch-first-clause - Db2 SQL
The FETCH FIRST clause limits the number of rows that can be fetched. It improves the performance of queries with potentially large result tables when only a limited number of rows are needed.
🌐
Oracle
docs.oracle.com › javadb › 10.8.3.0 › ref › rrefsqljoffsetfetch.html
The result offset and fetch first clauses
-- Fetch the first row of T SELECT * FROM T FETCH FIRST ROW ONLY -- Sort T using column I, then fetch rows 11 through 20 of the sorted -- rows (inclusive) SELECT * FROM T ORDER BY I OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY -- Skip the first 100 rows of T -- If the table has fewer than 101 records, ...
🌐
Intellipaat
intellipaat.com › home › blog › sql top, limit, fetch first clause
SQL TOP, LIMIT, FETCH FIRST Clause - Intellipaat
February 3, 2026 - Learn how to use SQL queries to select the first 10 rows of a table. Step-by-step instructions for limiting query results efficiently.