CREATE GLOBAL TEMPORARY TABLE test_table(id INT, value varchar2(10))
Table created.
INSERT INTO test_table VALUES(10,'A')
1 row(s) inserted.
INSERT INTO test_table VALUES(10,'B')
1 row(s) inserted.
INSERT INTO test_table VALUES(10,'C')
1 row(s) inserted.
INSERT INTO test_table VALUES(20,'A1')
1 row(s) inserted.
INSERT INTO test_table VALUES(30,'C1')
1 row(s) inserted.
INSERT INTO test_table VALUES(30,'D1')
1 row(s) inserted.
SELECT t.*, ROW_NUMBER () OVER (PARTITION BY t.id ORDER BY t.value) seq_group
FROM test_table t
| ID | VALUE | SEQ_GROUP | 10 | A | 1 | 10 | B | 2 | 10 | C | 3 | 20 | A1 | 1 | 30 | C1 | 1 | 30 | D1 | 2 |
|---|