------解决方案-------------------- --wm_concat()函数用法 with tb as ( select '王' name,'数学' course, 11 type, '2011-11-30 18:11:00' time from dual union all select '王' , '数学', 11, '2011-11-30 18:11:00' from dual union all select '王' , '语文', 12, '2011-10-30 18:11:00' from dual union all select '张' , '数学', 11, '2011-11-30 18:11:00' from dual )
select tt.name, wm_concat(tt.km), wm_concat(tt.sj) from ( select name, to_char(course), to_char(t.a) as km, to_char(type) || '/' || to_char(to_date(time,'yyyy-mm-dd hh24:mi:ss'), 'mm.dd') as sj from (select name, course, count(1) a, time, type from tb group by name,course,time,type) t ) tt group by tt.name
------解决方案--------------------
关联的话
SQL code
select b.groupa,WMSYS.WM_CONCAT(message) as messages from tableb b join tablea a on b.groupa = a.groupa group by b.groupa;
------解决方案--------------------
------解决方案-------------------- 上面 符号写反了
SQL code
with tableb as (
select 'ItemA' as groupa,'MessageA' as message from dual
union
select 'ItemA' as groupa,'MessageB' as message from dual
union
select 'ItemB' as groupa,'Messagec' as message from dual
)
select groupa,substr(max(sys_connect_by_path(message,',')),2) as message
from (select a.*,row_number()over(partition by groupa order by message) rn from tableb a )
group by groupa
start with rn=1
connect by rn-1=prior rn and groupa=prior groupa
order by 1