"if you encounter any errors in SAP, send me a screenshot at pramod@learntosap.com, and I will help you resolve the issue."

SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause

SQL TUTORIALS-

SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause

Introduction-


Trulli Trulli

-✅ SQL clauses TOP, LIMIT, FETCH FIRST, and ROWNUM are used to limit the number of rows returned in a result set. Different databases use different syntax for this....

✅ 1. TOP – (Used in SQL Server, MS Access):-



SELECT TOP 5 * FROM Employees;



✅ 2. LIMIT – (Used in MySQL, PostgreSQL, SQLite):-



SELECT * FROM Employees LIMIT 5;



✅ 3. FETCH FIRST – (Used in standard SQL, Oracle 12c+, DB2):-



SELECT * FROM Employees FETCH FIRST 5 ROWS ONLY;




✅ 4. ROWNUM – (Used in older versions of Oracle):-



SELECT * FROM Employees FETCH FIRST 5 ROWS ONLY;




✅ 5. SQL Server: TOP PERCENT with WHERE and ORDER BY Example:-



SELECT TOP 20 PERCENT * 
FROM Employees
WHERE Department = 'Sales'
ORDER BY Salary DESC;



May Be Like Important Link-

-Chart Of Account-OB13

-Define Plant-OX1

-Chart Of Account-OB13

-Define Financial Statement