select 200 gongzi,ltrim(sys_connect_by_path(name,','),',')
(select name,rownum rn
from tablename
where gongzi=200)
start with rn=1
connect by prior rn=rn-1
(select name,rownum rn
from tablename
where gongzi=200)
start with rn=1
connect by prior rn=rn-1
应该是:select 200 gongzi,max(ltrim(sys_connect_by_path(name,','),','))
(select name,rownum rn
from tablename
where gongzi=200)
start with rn=1
connect by prior rn=rn-1
的语句能用的
但查出来的是多条记录哦再加点语句就行了
select max(zhuhename)
from
(select 200 gongzi,ltrim(sys_connect_by_path(name,','),',') zhuhename
(select name,rownum rn
from tablename
where gongzi=200)
start with rn=1
connect by prior rn=rn-1)
那样查出来的就是最后全部合并名字的字符串
from (
select 人员姓名,工资,row_number over(partition by 工资 order by 人员编号) rn
from tablename
)
start with rn = 1
connect by prior rn = rn + 1
and prior 工资 = 工资
group by 工资
==============
这样写可以按照工资将相同工资的人名连在一起。呵呵,算是做一个扩充吧。