Top Keyword With Select Statement In SQL

In this artcle i will explain how to use the top keyword in a select query to get the top element from the table.
  • 1932

Introduction

The TOP clause allows us to specify how many rows to return. It is very useful on large tables with thousands of records. So we can use it in a select query to get the top element from the query.

Syntax

SELECT TOP  number|percent column_name(s)
FROM  table_name

Example

Firstly, create a table named Employee having columns (ID, F_Name, L_Name, Salary, Region and City) and insert some values.

Employee Table data

CreateTable-in-sql.jpg


To select Top 10 records from table

TOP-clause-in-sql.jpg

© 2020 DotNetHeaven. All rights reserved.