SELECT TOP in SQL

HOW TO USE SELECT TOP CLAUSE 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โ€™;


Posted

in

Tags:

Comments

Leave a Reply