首页 > 数据库技术 > 详细

oracle 多表查询

时间:2015-01-29 17:39:36      阅读:279      评论:0      收藏:0      [点我收藏+]

oracle 多表查询  1对多    多个数据放到一个字段内

select  id,zhzxm,fzhzxm,ltrim(max(sys_connect_by_path(xm, ‘,‘)), ‘,‘) xm
from (
select id,zhzxm,fzhzxm,xm,row_number() over(partition by id order by lrsj) rn  --标记相同的字段
from
(select t2.id id,t2.zhzxm zhzxm,t2.fzhzxm fzhzxm ,t1.xm xm,t1.lrsj lrsj from t_yj_yjzhy t1 left join t_yj_yjzhzxx t2 on t1.yjzhzid = t2.id)
)
start with rn=1
connect by prior rn=rn-1 and prior id=id
group by id,zhzxm,fzhzxm



oracle 多表查询

原文:http://blog.csdn.net/u011513323/article/details/43273383

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!