更新时间:2023-11-22 14:59:34
最简单的解决方案:
SQL> select * from t69
2 /
NAME NICKNAME ID
---------- ---------- ----------
Joe Joey 14
Joe 14
Michael 15
Mick 15
Mickey 15
SQL> select max(name) as name
2 , max(nickname) as nickname
3 , id
4 from t69
5 group by id
6 /
NAME NICKNAME ID
---------- ---------- ----------
Joe Joey 14
Michael Mickey 15
SQL>
如果您有 11gR2,您可以使用 新的-奇怪的 LISTAGG() 函数 但除此之外,将上述语句包装在连接 NAME 和 NICKNAME 列的 SELECT 中很简单.
If you have 11gR2 you could use the new-fangled LISTAGG() function but otherwise it is simple enough to wrap the above statement in a SELECT which concatenates the NAME and NICKNAME columns.