In this article, we will learn how to use SQL SELECT TOP queries and we will also reinforce this learning using examples.
The TOP clause allows us to limit the result set of the queries according to the number of rows or the percentage of rows. In general, the TOP and ORDER BY construction are used together. Otherwise, the TOP clause will return the N number of rows in an uncertain order. For this reason, it is the best practice to use the TOP clause with an ORDER BY to obtain a certain sorted result.
The syntax of the TOP clause is as follows:
SELECT TOP (expression) [PERCENT]
[WITH TIES]
FROM
table_name
#sql commands #t-sql #sql