两个表,主从关系,A表(主表),B表(从表)
A
字段1 字段2
1 1
2 2
3 3
B
字段1 字段21 字段3
1 1 001
1 2 002
1 3 003
查询结果是
字段1 字段合成
1 001;002;003
2
3
A
字段1 字段2
1 1
2 2
3 3
B
字段1 字段21 字段3
1 1 001
1 2 002
1 3 003
查询结果是
字段1 字段合成
1 001;002;003
2
3
from a,b
where a.col1=b.col1(+)
group by a.col1
哈哈!!在写一次,然后在版主置顶!!!
from a,b
where a.col1=b.col1(+)
group by a.col1这是10g以上的代码
如果是9i的
select col1,substr(max(sys_connect_by_path(col3,';')),2)newstr
from(
select a.col1,b.col3,
row_number()over(partition by a.col1 order by b.col2)rn
from a,b
where a.col1=b.col1(+) )
connect by prior col1=col1 and prior rn=rn-1
start with rn=1
group by col1
如果外面不聚合也必须在子查询里聚合,一样的