HOW TO USE SELECT TOP CLAUSE IN SQL

SELECT TOP IN SQL

SELECT TOP

SELECT TOP clause is used to specify the number of records to return from top of the table.

Syntax of TOP clause in SQL server –

SELECT TOP number|PERCENT ColumnName1,…,ColumnNameN

FROM <TableName>

WHERE<condition> ;   

Example of TOP clause in SQL server –To select top 10 records of customers from city Berlin from customers table

SELECT TOP 10  *

FROM Customers

WHERE city=‘Berlin’;

Example- To select top 10%  records of customers from city Berlin from customers table

SELECT TOP 10 PERCENT *

FROM  Customers

WHERE city=‘Berlin’;


Leave a Reply

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