Example

Teradata Vantageā„¢ SQL Functions, Expressions, and Predicates

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1145-162K

Display each item, its total sales, and its sales rank for the top 100 selling items.

   SELECT itemID, sumPrice, RANK(sumPrice)
   FROM 
      (SELECT a1.itemID, SUM(a1.Price)
      FROM Sales a1
      GROUP BY a1.itemID AS T1(itemID, sumPrice)
      QUALIFY RANK(sumPrice) <=100;