Returns the top-ranked rows to from the SELECT operation.
You cannot specify a TOP n operator if the view definition also specifies any of the following:
- DISTINCT operator
- SAMPLE clause
- QUALIFY clause
- Subquery, that is, a subquery within a view definition cannot contain a TOP operator.
Views that specify a TOP operator are not updatable.
You can also specify an ORDER BY clause with the TOP operator. Otherwise, ORDER BY clauses are not valid within view definitions.
The sort expression for the ORDER BY clause cannot contain BLOBs, CLOBs, UDTs, columns with Period or Geospatial types, or ordered analytic functions.
TOP performs as well or better as the ordered analytic functions QUALIFY RANK() or QUALIFY ROW_NUMBER() that can be used in a similar fashion.
- n
- A DECIMAL or an INTEGER value for the number of rows to return from the SELECT operation.
- m PERCENT
- Returns only m percent of rows from the SELECT operation, where m can be either a DECIMAL or an INTEGER value.