将多行数据合并为一行

来源:互联网 发布:数据采集仪数据存储 编辑:程序博客网 时间:2024/06/04 17:50

oracle语法:
  select country,wmsys.wm_concat(city) as city from test group      bycountry

 

mysql语法:
select country,GROUP_CONCAT(city order by city separator",") as city from test GROUP BY country

 

sqlserver语法:
select country,sys_connect_by_path(city,',') as city from test

 

效果如图所示: