我的问题是否有任何oracle声明。
EG。 TableA有两列:columnA and columnB
ColumnA ColumnB
-------------------
A WA
A WA
B WA
B WA
C WA
A CA
A CA
B CA
B CA
C CA
我想要的是:自动编号Group by ColumnA
Auto ColumnA ColumnB
-----------------------
1 A WA
2 A WA
3 A CA
4 A CA
1 B WA
2 B WA
3 B CA
4 B CA
1 C WA
2 C CA
答案 0 :(得分:1)
您可以使用ROW_NUMBER功能。按columnA分组并指定一些order by子句。
SELECT ROW_NUMBER () OVER (PARTITION BY columnA ORDER BY columnB) as "auto",
columnA, columnB
FROM table;