当前位置:网站首页>SQL implementation merges multiple rows of records into one row
SQL implementation merges multiple rows of records into one row
2022-07-29 00:04:00 【m0_ sixty-seven million four hundred and three thousand and thi】
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 ~~~
边栏推荐
- Leetcode63. Different paths II
- 电商数据模型设计
- Is the declarative code of compose so concise?
- CMake 基础学习
- Leetcode63. 不同路径 II
- 【TA-霜狼_may-《百人计划》】图形3.6 纹理压缩——包体瘦身术
- The failure rate is as high as 80%. How to correctly complete the strategic planning of digital transformation?
- 【C】 Introduction and Simulation Implementation of ATOI and offsetof
- VS2005透过SourceOffSite访问VSS2005的设置方法「建议收藏」
- Interpretation of ISO 13400 (doip) standard
猜你喜欢

JS高级 之 ES6~ES13 新特性

pycharm新建项目

失败率高达80%,数字化转型如何正确完成战略规划?

centos7安装mysql8

JS advanced ES6 ~ es13 new features

多传感器融合定位(二)——基于地图的定位

YOLOV5学习笔记(一)——原理概述

Compose 的声明式代码如此简洁?

Kingbasees client programming interface guide ODBC (4. Create data source)

Urease -- Characteristics and determination scheme of Worthington jack bean urease
随机推荐
CANoe应用案例之DoIP通信
E-commerce data model design
考过HCIP入职心仪公司,分享华为认证学习经历及心得
台式机dp接口在哪(主机没有dp接口怎么办)
Hutool official website (is hutool easy to use)
PowerCLi 批量添加esxi到vCenter
centos7安装mysql8
1-8 props的基础使用
Classification and determination method of Worthington stemxyme
Zibo station construction guide (aigler)
实时数仓:滴滴的实时数仓落地实践
SQL实现将多行记录合并成一行
Leetcode60. permutation sequence
Worthington -- Specification of Worthington trypsin inhibitor
【C】逆序字符串(俩种递归思路)
[detailed and super simple] how to use websocket links
实时数仓:美团基于Flink的实时数仓建设实施
通配符 SSL/TLS 证书
Leetcode59. 螺旋矩阵 II
What is a driver signature and how does the driver get a digital signature?