日期:2014-05-17 浏览次数:21124 次
with t as( select '日本' country,'东京' city from dual union all select '日本','大坂' from dual union all select '中国','上海' from dual union all select '中国','北京' from dual union all select '中国','深圳' from dual )select country,wm_concat(city) from t group by country COUNTRY WM_CONCAT(CITY) ------- -------------------------------------------- 日本 东京,大坂 中国 上海,深圳,北京
------解决方案--------------------
with t as (
select '日本' as country, '东京' as city from dual
union all
select '日本', '大坂' from dual
union all
select '中国', '上海' from dual
union all
select '中国', '北京' from dual
union all
select '中国', '深圳' from dual
)
select country,wm_concat(city) from t
group by country
--
日本 东京,大坂
中国 上海,深圳,北京