3

オラクルを使用しています。

このサンプルのランダムなコンテンツを含むテーブルがあるとします。

columnA     | columnB  | content
--------------------------------
AfBkxZ      | 292      | a
LDglkK      | 181      | b
AfBkxZ      | 51       | c
AfBkxZ      | 315      | d
LDglkK      | 808      | e
Cee89g      | 1        | f

columnA の各値に一意の番号を持ち、その値を持つ columnA の行内に番号を記録するビューが必要です。

上記のサンプル データに基づいて求められる結果:

Group_number | Record_number | columnB | content
------------------------------------------------
1            | 2             | 292     | a             (1.2)
3            | 1             | 181     | b             (3.1)
1            | 1             | 51      | c             (1.1)
1            | 3             | 315     | d             (1.3)
3            | 2             | 808     | e             (3.2)
2            | 1             | 1       | f             (2.1)

で入手できrecord_numberますrow_number() over (partition by columnA order by columnB asc)

group_number実際には old のフレンドリなシーケンス エイリアスであるを取得するにはどうすればよいcolumnAですか?

ありがとうございました。

4

1 に答える 1

6

dense_rankcolumnA に番号を付けるために使用できます。

dense_rank() over (order by columnA)
于 2011-05-30T11:59:32.273 に答える