ROW_NUMBER Function Example | Teradata Vantage - Example - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

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
2024-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢

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;

Result:

   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