17.05 - Rules and Restrictions for the TOP n Operator - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Advanced SQL Engine
Teradata Database
Release Number
Release Date
January 2021
Content Type
Programming Reference
Publication ID
English (United States)
You cannot specify the TOP n operator in any of these SQL statements or statement components:
  • Correlated subquery
  • Subquery in a search condition
  • Seed statement or recursive statement in a CREATE RECURSIVE VIEW statement or WITH RECURSIVE statement modifier
  • Subselects of set operations.
You cannot specify these options in a SELECT statement that specifies the TOP n operator:
  • DISTINCT option
  • QUALIFY clause
  • SAMPLE clause
  • WITH clause

    This restriction refers to the WITH clause you can specify for summary lines and breaks. See WITH Clause. The nonrecursive WITH statement modifier that can precede the SELECT keyword can be included in statements that also specify the TOP n operator. See WITH Modifier.

  • ORDER BY clause where the sort expression is an ordered analytical function.

You cannot specify the n value of a TOP n specification as a USING parameter for iterated array processing. For an example, see Example: Non-Support for Iterated Requests With TOP n.