固定只显示2个子女的信息:
A、要两个子女以上的才显示
with tmp1 as
(select b.person_id as id,b.name||':'||b.sex childs
from B b
where b.person_id in (select a.person_id
from B a
group by a.person_id
having count(a.id)>1)
)
select t.id,wmsys.wm_concat(t.childs) childs
from tmp1 t
group by t.id;
1 1 luci:女,tom:男 (这个地方会出现反过来 如果没有影响则不用修改,如果要按照B表ID来拍的话,还需要修改)
B:没有这个【只显示2个子女】要求:
with tmp1 as
(select b.person_id as id,b.name||':'||b.sex childs
from B b
)
select t.id,wmsys.wm_concat(t.childs) childs
from tmp1 t
group by t.id;
显示结果:
1 tom:男,luci:女
2 lili:女
方法是有,我只是很好奇为什么要这么做呢,一个左连接可以获取两列,让他们排成一列什么场景会用到呢