1#SELECT * FROM Customers LIMIT number_of_rows;
2
3SELECT * FROM Customers LIMIT 3;
4#return first 3 rows
5
6
7
8#SELECT * FROM Customers LIMIT start,number_of_rows;
9
10SELECT * FROM Customers LIMIT 0,3;
11#return 3 rows starting from 0
12
13SELECT * FROM Customers LIMIT 2,3;
14#return 3 rows starting from 2
15
16
17
18#SELECT * FROM Customers LIMIT number_of_rows OFFSET y;
19
20SELECT * FROM Customers LIMIT 2 offset 3;
21#skip the first 3 rows and then return the next 2 rows
1-- MySql
2SELECT * FROM emp ORDER BY sal DESC LIMIT 5;
3-- SQL Server
4SELECT TOP 5 * FROM emp ORDER BY sal DESC;
5-- Oracle < 11g
6SELECT * FROM ( SELECT * FROM emp ORDER BY sal DESC ) WHERE ROWNUM <= 5;
7-- Oracle 12c +
8SELECT * FROM emp ORDER BY sal DESC FETCH FIRST 5 ROWS ONLY;
1SELECT expressions
2FROM tables
3[WHERE conditions]
4[ORDER BY expression [ ASC | DESC ]]
5LIMIT number_rows [ OFFSET offset_value ];
1SELECT ROWNUM, a.*
2FROM (SELECT customers.*
3 FROM customers
4 WHERE customer_id > 4500
5 ORDER BY last_name) a;