江清风 2017-05-23 01:47 采纳率: 0%
浏览 1758
已结题

oracle数据库中,要求不能用wm_concat函数合并值

问题: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;

  • 写回答

2条回答 默认 最新

  • wangwx0824 2017-05-23 06:30
    关注

    select s_type,wm_concat(s_mc) as s_mc from t_thz_1 group by s_type,s_type

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!