各位大侠
在表t1中,有4个字段a,b,c,d
t1表中记录为:
a b c d
2008-8-1 20080634 赵小波 3837594
2008-8-1 20080634 赵小波 1111111
希望的查询结果为: a b c d
2008-8-1 20080634 赵小波 3837594 1111111小弟在线等!!!
在表t1中,有4个字段a,b,c,d
t1表中记录为:
a b c d
2008-8-1 20080634 赵小波 3837594
2008-8-1 20080634 赵小波 1111111
希望的查询结果为: a b c d
2008-8-1 20080634 赵小波 3837594 1111111小弟在线等!!!
[code=SQL]select a,b,c,substr(max(Sys_Connect_By_Path(d,',')),2) d from(
select a,b,c,d,row_number()over(partition by a,b,c order by d)rn
from t1)t
start with t.rn=1
connect by t.rn=prior t.rn-1 and
t.a=prior t.a and t.b=prior t.b
and t.c=prior t.c
group by a,b,c code]
select a,b,c,d,row_number()over(partition by a,b,c order by d)rn
from t1)t
start with t.rn=1
connect by t.rn=prior t.rn-1 and
t.a=prior t.a and t.b=prior t.b
and t.c=prior t.c
group by a,b,c
select a,b,c,d,row_number()over(partition by a,b,c order by d)rn
from t1)t
start with t.rn=1
connect by t.rn=prior t.rn+1 and
t.a=prior t.a and t.b=prior t.b
and t.c=prior t.c
group by a,b,c
good job!!!