How To Use TOP Clause In SQL

Introduction

In this article, we will learn how to use the TOP Clause with a SQL select query.

The SELECT TOP clause is used to specify the number/percent of records to return.

The SELECT TOP clause is useful with thousands of records on large tables.

Syntax

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

Example-1

The subsequent statement would return the first two records from the Article table.

SELECT TOP 2 * FROM Article;

Example-2

The subsequent statement would return the first 50% of the records from the Article table.

SELECT TOP 50 PERCENT * FROM Article;

 

Also, check How To Display SQL Data In Descending Order

Submit a Comment

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

Subscribe

Select Categories