What the TOP n Operator Does - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530
You can use the TOP n operator in these ways:
  • The TOP n operator returns only a subset of the rows in the query result set. For example, this query returns 10 rows from the orders table:
    SELECT TOP 10 *
    FROM orders;
  • To get a subset of the data from an ordered set, specify the TOP n operator with an ORDER BY clause. For example, this query returns the last five orders shipped:
    SELECT TOP 5 *
    FROM orders
    ORDER BY ship_date DESC;
  • If the TOP n operator specifies a number greater than the number of rows in the query result set, then the query returns all of the rows in the query result set without returning an error.
  • As the size of n increases, the performance of TOP n gradually degrades.
  • You can use parameters to pass values for n from: