假设我有一张table:
+----+------------+------------+
| ID | NAME1 | NAME2 |
+----+------------+------------+
| A1 | DAVE | DAN |
| A1 | DOR | MON |
| A2 | STEPHAN | ARKEL |
| A3 | ASH | CATCHAM |
| A4 | RON | DON |
| A4 | OFIR | DOL |
| A4 | OFRA | SOL |
+----+------------+------------+
我想根据id连接,如果下一行具有相同的id,则添加两个名称,如下所示:
+----+-----------------------------------+
| ID | NEW_NAME |
+----+-----------------------------------+
| A1 | DAVE~~DAN^^DOR~~MON |
| A2 | STEPHAN~~ARKEL |
| A3 | ASH~~CATCHAM |
| A4 | RON~~DON^^OFIR~~DOL^^OFRA~~SOL |
+----+-----------------------------------+
谢谢。
1条答案
按热度按时间ax6ht2ek1#
你可以做:
请参见在sql<>fiddle上运行示例。