当前位置:网站首页>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 ~~~
边栏推荐
- SAP temporary tablespace error handling
- 多传感器融合定位(二)——基于地图的定位
- Eight performance analysis indicators of effective supply chain management (Part 1)
- mysql索引失效的常见9种原因详解
- Js判断数据类型的4种⽅式
- 【C】 Introduction and Simulation Implementation of ATOI and offsetof
- Leetcode64. Minimum path sum
- EN 12101-8:2011 smoke dampers for smoke and heat control systems - CE certification
- Word中的\n是什么?:^p
- JS advanced ES6 ~ es13 new features
猜你喜欢
NAT如何配置地址转换
Connection pool - return connection details (Part 2)
CANoe应用案例之DoIP通信
VMware VCSA 7.0 Install
多传感器融合定位(三)——惯性技术
Powercli batch add esxi to vCenter
Classification and determination method of Worthington stemxyme
DevOps在物联网解决方案中的应用
EN 1873 assembly accessories for roofing - plastic single roof lamps - CE certification
失败率高达80%,数字化转型如何正确完成战略规划?
随机推荐
Jincang database kingbasees client Programming Interface Guide - ODBC feature support constraints
What is in word?:^ p
Apple's official website is being updated to maintain the apple store. Products such as the iPhone 13 / pro of the Bank of China will enjoy a maximum discount of 600 yuan
Interpretation of ISO 13400 (doip) standard
Doip communication of canoe application case
Wildcard ssl/tls certificate
Leetcode59. Spiral matrix II
Js判断数据类型的4种⽅式
熊市下PLATO如何通过Elephant Swap,获得溢价收益?
【MySQL 8】Generated Invisible Primary Keys(GIPK)
EN 12101-8:2011 smoke dampers for smoke and heat control systems - CE certification
VirtualLab基础实验教程-8.傅里叶变换(1)
Pycharm configuring the running environment
PMP Exam countdown, look at 3A pass bag!
Multisensor fusion positioning (III) -- inertial technology
Review of categories 1-4
Type 1-5 components
Use pytoch to quickly train the network model
研发效能的道法术器
PHP poster QR code synthesis