当前位置:网站首页>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 ~~~
边栏推荐
- Interface test weather API
- Oauth2.0 - using JWT to replace token and JWT content enhancement
- Difference between shortest path and minimum spanning tree
- MySQL帶二進制的庫錶導出導入
- Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)
- Numerical method for solving optimal control problem (I) -- gradient method
- Print time Hahahahahaha
- 远端rostopic的本地rviz调用及显示
- Docker advanced learning (container data volume, MySQL installation, dockerfile)
- SVN分支管理
猜你喜欢

有意思的鼠标指针交互探究

Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)

ruoyi接口权限校验

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

Local rviz call and display of remote rostopic

scroll-view指定滚动元素的起始位置

Use abp Zero builds a third-party login module (I): Principles

JMeter linked database

Install VM tools

剖析虚幻渲染体系(16)- 图形驱动的秘密
随机推荐
2022 cisp-pte (III) command execution
Oracle database synonym creation
Kubesphere - Multi tenant management
Phpstudy setting items can be accessed by other computers on the LAN
Zhiniu stock project -- 05
Decision tree of machine learning
Exportation et importation de tables de bibliothèque avec binaires MySQL
Cesium 点击获三维坐标(经纬度高程)
[leetcode] day93 - intersection of two arrays II
Difference between shortest path and minimum spanning tree
Project summary --2 (basic use of jsup)
Printer related problem record
scroll-view指定滚动元素的起始位置
Request weather interface format, automation
Use @data in Lombok to simplify entity class code
YOLOV2学习与总结
冒泡排序的简单理解
Leetcode problem solving summary, constantly updating!
Heap sort and priority queue
Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)