当前位置:网站首页>SQL implementation merges multiple rows of records into one row
SQL implementation merges multiple rows of records into one row
2022-07-03 06:28:00 【Reasonable meow~~】
SQL Realize merging multiple lines of records into one line
We are in the process of data development , It's a common demand , Is to merge multiple rows into one row , And separated by specific characters .
1、 Before data processing

2, Result data display

3,hive Processing mode
stay hive Inside , use concat_ws Function processing
Format : concat_ws(‘ Separator ’,collect_set/collect_list( Field ))
Parameter interpretation :
concat_ws: Merge multiple lines into one line of functions
collect_set: Composite array , The data has been de duplicated
collect_list: Composite array , Data not de duplicated
SQL Script :
select school,concat_ws(',',collect_set(name)) from student
group by school;
4,MySQL Processing mode
GROUP_CONCAT( Field Separator )
Be careful :MySQL stay GROUP_CONCAT Function , Weight removal needs to be used distinct keyword , If you need to sort before merging , You can also use order by keyword .
select school,GROUP_CONCAT(name,',') from student
group by school;
I'm meow , If you have problems, please communicate at any time ~~~
边栏推荐
- [untitled] 5 self use history
- Kubesphere - build Nacos cluster
- Pdf files can only print out the first page
- 2022 cisp-pte (III) command execution
- About the difference between count (1), count (*), and count (column name)
- 远端rostopic的本地rviz调用及显示
- Exportation et importation de tables de bibliothèque avec binaires MySQL
- 【系统设计】邻近服务
- YOLOV2学习与总结
- ODL framework project construction trial -demo
猜你喜欢

Oauth2.0 - Introduction and use and explanation of authorization code mode

Install VM tools

远端rostopic的本地rviz调用及显示

有意思的鼠標指針交互探究

10万奖金被瓜分,快来认识这位上榜者里的“乘风破浪的姐姐”
![[set theory] relational closure (relational closure solution | relational graph closure | relational matrix closure | closure operation and relational properties | closure compound operation)](/img/a4/00aca72b268f77fe4fb24ac06289f5.jpg)
[set theory] relational closure (relational closure solution | relational graph closure | relational matrix closure | closure operation and relational properties | closure compound operation)

【5G NR】UE注册流程

Project summary --2 (basic use of jsup)

Example of joint use of ros+pytoch (semantic segmentation)

Cesium 点击获三维坐标(经纬度高程)
随机推荐
Kubesphere - build MySQL master-slave replication structure
Scripy learning
Kubesphere - Multi tenant management
opencv鼠标键盘事件
技术管理进阶——你了解成长的全貌吗?
【C#/VB.NET】 将PDF转为SVG/Image, SVG/Image转PDF
Une exploration intéressante de l'interaction souris - pointeur
How matlab modifies default settings
认识弹性盒子flex
从小数据量分库分表 MySQL 合并迁移数据到 TiDB
10万奖金被瓜分,快来认识这位上榜者里的“乘风破浪的姐姐”
使用conda创建自己的深度学习环境
Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide
Use selenium to climb the annual box office of Yien
Merge and migrate data from small data volume, sub database and sub table Mysql to tidb
Install VM tools
【系统设计】邻近服务
Oauth2.0 - user defined mode authorization - SMS verification code login
MATLAB如何修改默认设置
[leetcode] day93 - intersection of two arrays II