25.2. group_concat() 列传行

简介:
SELECT tags FROM neo.article;

linux
redis
mysql
java
php
		

tags字段专为一行显示

SELECT group_concat(tags) FROM neo.article;		

linux,redis,mysql,java,php
		

distinct 去除重复数据

select group_concat(distinct author) from neo.article;		
		

以id分组,把name字段的值打印在一行,分号分隔

select id,group_concat(tags separator ';') from neo.article group by tags;		
		

排序结果

select group_concat(distinct author order by author desc) from neo.article;			
		





原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
|
2月前
|
关系型数据库 MySQL
MySQL中CONCAT() ,CONCAT_WS() ,GROUP_CONCAT()的用法
MySQL中CONCAT() ,CONCAT_WS() ,GROUP_CONCAT()的用法
16 2
|
SQL 自然语言处理 关系型数据库
【Hive】函数 concat 、concat_ws 、concat_group 的区别
【Hive】函数 concat 、concat_ws 、concat_group 的区别
719 0
|
5月前
ROW_NUMBER() OVER()函数用法详解 (分组排序 例子多)
ROW_NUMBER() OVER()函数用法详解 (分组排序 例子多)
42 0
|
关系型数据库 PostgreSQL
PostgreSQL listagg within group (order by) 聚合兼容用法 string_agg ( order by) - 行列变换,CSV构造...
标签 PostgreSQL , order-set agg , listagg , string_agg , order 背景 listagg — Rows to Delimited Strings The listagg function transforms values from a g...
5865 0
|
8月前
|
SQL 关系型数据库 MySQL
MySQL中concat()、concat_ws()、group_concat()三个函数的使用技巧案例与心得总结
MySQL中concat()、concat_ws()、group_concat()三个函数的使用
85 0
MySQL中concat()、concat_ws()、group_concat()三个函数的使用技巧案例与心得总结
|
SQL Oracle 关系型数据库
【SQL开发实战技巧】系列(十一):拿几个案例讲讲translate|regexp_replace|listagg|wmsys.wm_concat|substr|regexp_substr常用函数
translate|regexp_replace|listagg|wmsys.wm_concat|substr|regexp_substr常用函数。如何使用translate或regexp_replace提取姓名的大写首字母缩写、如何使用translate或regexp_replace按字符串中的数值排序、如何聚合表中的行创建一个以逗号分隔拼接的字符串(函数LISTAGG、wmsys.wm_concat)、如何使用substr或regexp_substr提取第N个分隔符的子串、如何分解IP地址
【SQL开发实战技巧】系列(十一):拿几个案例讲讲translate|regexp_replace|listagg|wmsys.wm_concat|substr|regexp_substr常用函数
group by+group_concat解决的小问题
group by+group_concat解决的小问题
77 0
|
关系型数据库 MySQL 索引
mysql函数,concat,日期处理,分组
mysql函数,concat,日期处理,分组
141 0
|
关系型数据库 MySQL
十一、GROUP_CONCAT的使用
十一、GROUP_CONCAT的使用
406 0
|
关系型数据库 MySQL 测试技术
论证select count(*)和select count(1)
论证select count(*)和select count(1)
110 0