TOP Clause Syntax | SQL SELECT Statements | Teradata Vantage - TOP Clause Syntax - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantage™
TOP { integer | decimal } [ PERCENT ] [ WITH TIES ]
You cannot specify NORMALIZE with TOP.

Syntax Elements

integer
A nonzero, positive INTEGER literal indicating the number of rows to return.
If the PERCENT option is specified, the system returns integer% of the total rows available, where 100 ≥ integer >  0.
decimal
A nonzero, positive DECIMAL literal indicating the number of rows to return.
If the PERCENT option is specified, the system return decimal% of the total rows available, where 100 ≥ decimal  >  0.
If the PERCENT option is not specified, decimal cannot include a decimal point.
PERCENT
The integer or decimal value indicates a percentage of the rows to return.
The number of rows returned is (n/100 * result set row count), where n is the integer or decimal value.
If the number is not an integer, and the fractional part of the number ≥ 0.000000000000001, the next highest integer is used.
For fractions < 0.000000000000001, the number is truncated.
The TOP n operator is referred to as TOP m when you specify the PERCENT option for clarification purposes.
WITH TIES
Rows returned by the query include the specified number or percentage of rows in the ordered set produced by the ORDER BY clause, plus any additional rows where the value of the sort key is the same as the value of the sort key in the last row that satisfies the specified number or percentage of rows.
The WITH TIES option is ignored if the SELECT statement does not also specify an ORDER BY clause.