SQL查询连接Oracle中多行的列值是否可以构造SQL来连接多行的列值?以下是一个例子:表APID
A
B
C表BPID SEQ Desc
A 1 Have
A 2 a nice
A 3 day.
B 1 Nice Work.
C 1 Yes
C 2 we can
C 3 do
C 4 this work!SQL的输出应该是-PID Desc
A Have a nice day.
B Nice Work.
C Yes we can do this work!因此,基本上,输出表的Desc列是表B中SEQ值的级联吗?对SQL有帮助吗?
3 回答
慕盖茨4494581
TA贡献1850条经验 获得超11个赞
LISTAGG
:
SELECT pid, LISTAGG(Desc, ' ') WITHIN GROUP (ORDER BY seq) AS descriptionFROM B GROUP BY pid;
A
pids
注:LISTAGG
VARCHAR2
添加回答
举报
0/150
提交
取消