TOP Function Syntax | Teradata Vantage - TOP - Analytics Database - Teradata Vantage

Time Series Tables and Operations

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
2023-10-30
dita:mapPath
tuc1628112453431.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
sfz1493079039055
lifecycle
latest
Product Category
Teradata Vantageā„¢

Returns the largest number_of_values in the value_expression for each group, with or without ties. TOP is a single-threaded function.

To invoke the time series version of this function, use the GROUP BY TIME clause. For more information, see GROUP BY TIME Clause.

Syntax

TOP [ WITH TIES ] ('number_of_values', 'value_expression')

Syntax Elements

number_of_values
Teradata integer value representing the number of values to return.
value_expression
A literal or column expression from which the top values are taken.

The value_expression cannot be a reference to a view column derived from a function, and cannot contain any ordered analytical or aggregate functions.

Return Value

The return value is the same as the input data type.

Nulls are not included in the computation.

Usage Notes

TOP is valid only for numeric data.

WITH TIES implies the rows returned by the query include the specified number of rows in the ordered set for each time bucket, plus any additional rows where the sort key value is the same as the value of the sort key in the last row satisfying the specified number or percentage of rows. If this clause is omitted and ties are found, the earliest value in terms of timecode is returned.