ROW_NUMBER Function Example | VantageCloud Lake - Example: ROW_NUMBER Function - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

To order salespersons based on sales within a sales region, the following SQL query may 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