oracle 中怎么将一个列中的数据分为多行显示
1个回答
2015-12-02
展开全部
固定只显示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:女
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:女
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询