The SELECT TOP clause is used to return specific number of records with thousands of records. It is used to select top N number of records from a table. We can use number or percent to select record.
TOP clause is not supported by all the databases.
For e.g- MySQL uses LIMIT
Oracle uses ROWNUM
MS SQL uses TOP
1. SELECT TOP:-
Syntax of SELECT TOP:-
SELECT TOP number|percent column_name(s)
FROM table_name WHERE [condition] ; |
2.LIMIT:-
Syntax of LIMIT:-
SELECT column_name(s)
FROM table_name
LIMIT number; |
To display elements in ascending or descending order:-
SELECT expressions
FROM tables
[WHERE conditions]
[ORDER BY expression [ ASC | DESC ]]
LIMIT number_rows [ OFFSET offset_value ];
|
3. ROWNUM:-
Syntax of ROWNUM:-
SELECT column_name(s)
FROM table_name
WHERE ROWNUM <= number; |
In place of number we will give the number of rows we want to be selected.
0 Comment(s)