SQL – Select Top Records

Table Of Contents:

  1. What Is Select Top Records?
  2. Syntax Of Select Top Records.
  3. Examples Of Select Top Records.

(1) What Is Select Top Records ?

  • Sometimes you want to see only the top records.
  • You can use the “SELECT TOP” clause to select top ‘n’ records.

(2) Syntax Of Select Top Records ?

Syntax: SQL Server / MS Access Syntax:

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

Syntax: MySQL Syntax:

SELECT column_name(s)
FROM table_name
WHERE condition
LIMIT number;

(3) Examples Of Select Top Records ?

Demo Data:

Example-1: SQL Server/MS Access

SELECT TOP 3 * FROM Customers;

Example-2:  MySQL Server

SELECT * FROM Customers LIMIT 3;

Example-3: SQL Server/MS Access

SELECT TOP 50 PERCENT * FROM Customers;

Leave a Reply

Your email address will not be published. Required fields are marked *