SQL SELECT distinct | SQL SELECT TOP, LIMIT, ROWNUM

The SQL SELECT distinct can be used to return the specified number of records, it is a very useful clause on a large table with thousands of record available in the table and all database systems support the SELECT TOP Clause.

SQL SELECT Distinct syntax

SQL SELECT TOP

SELECT TOP n column-names
  FROM table-name
SELECT TOP 5 Id, CustomerName, ProductPrice, Quantity
  FROM ProductSale
 ORDER BY UnitPrice DESC
ProductSale
Id
CustomerName
ProductPrice
Quantity
Result: Finally 5 Records
Therefore Below is a selection from the “product sales” table:

Id CustomerName ProductPrice Quantity
1 Abhishek 2500 70
22 Devendra 7500 30
12 Sonu 4500 90
32 Yahim 4100 80
172 Zamin 2900 110

SQL Server / MS Access Syntax

SELECT TOP number|percent column_name(s)
FROM table_name;

similarly, Equivalent in MySQL and Oracle

MySQL

SELECT column_name(s)
FROM table_name
LIMIT number;

Oracle Syntax

SELECT column_name(s)
FROM table_name
WHERE ROWNUM <= number;

PERCENT Example

SELECT TOP 50 PERCENT * FROM Customers;

Resource
SQL