问题:oracle数据库中,要求不能用wm_concat函数,合并值,希望得到结果如下:
s_type s2
水果 葡萄,哈密瓜,香瓜,火龙果
蔬菜 西兰花,茼蒿,茄子
坚果 核桃,巴旦木
数据如下:
create table t_thz_1(
n_id number(10),
s_mc varchar2(100),
s_type varchar2(10)
);
truncate table t_thz_1;
insert into t_thz_1(n_id,s_mc,s_type)
select 1 n_id,'葡萄' s_mc,'水果' s_type from dual union all
select 2 n_id,'哈密瓜' s_mc,'水果' s_type from dual union all
select 3 n_id,'西兰花' s_mc,'蔬菜' s_type from dual union all
select 4 n_id,'核桃' s_mc,'坚果' s_type from dual union all
select 5 n_id,'茼蒿' s_mc,'蔬菜' s_type from dual union all
select 6 n_id,'香瓜' s_mc,'水果' s_type from dual union all
select 7 n_id,'巴旦木' s_mc,'坚果' s_type from dual union all
select 8 n_id,'茄子' s_mc,'蔬菜' s_type from dual union all
select 10 n_id,'火龙果' s_mc,'水果' s_type from dual
;
commit;