例: RANK(ANSI)とDENSE_ RANK(ANSI)の相違の検出 - Teradata Database - Teradata Vantage NewSQL Engine - RANK(ANSI)関数の例。

Teradata Vantage™ SQL関数、演算子、式および述部

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
2019年3月
Language
日本語
Last Update
2019-10-29
dita:mapPath
ja-JP/xzf1512079057909.ditamap
dita:ditavalPath
ja-JP/xzf1512079057909.ditaval
dita:id
B035-1145
Product Category
Software
Teradata Vantage

次のSQL文は、RANK(ANSI)とDENSE_RANK(ANSI)との違いを示しており、sales_regionおよびsales_amount別にsales_personのRANKおよびDENSE_RANKを返します。

SELECT sales_person, sales_region, sales_amount,
 RANK() OVER
    (PARTITION BY sales_region ORDER BY sales_amount DESC) as "Rank",
 DENSE_RANK() OVER
    (PARTITION BY sales_region ORDER BY sales_amount DESC) as "DenseRank"
 FROM sales_table;
sales_person sales_region sales_amount Rank DenseRank
Garabaldi East 100 1 1
Baker East 100 1 1
Fine East 89 3 2
Adams East 75 4 3
Edwards West 100 1 1
Connors West 99 2 2
Davis West 99 2 2
Russell West 50 4 3