16.20 - Example - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Release Date
March 2019
Content Type
Programming Reference
Publication ID
B035-1145-162K
Language
English (United States)

To order salespersons based on sales within a sales region, the following SQL query might yield the following results.

   SELECT ROW_NUMBER() OVER (PARTITION BY sales_region 
                             ORDER BY sales_amount DESC),
   sales_person, sales_region, sales_amount
   FROM sales_table;
   
   Row_Number()  sales_person  sales_region  sales_amount
   ------------  ------------  ------------  ------------
              1  Baker         East                   100
              2  Edwards       East                    99
              3  Davis         East                    89
              4  Adams         East                    75
              1  Garabaldi     West                   100
              2  Connors       West                    99
              3  Fine          West                    99