当前位置:网站首页>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 ~~~
边栏推荐
- [detailed and super simple] how to use websocket links
- 实时数仓:滴滴的实时数仓落地实践
- 【C】喝汽水,找单身狗问题
- PowerCL 批量创建及管理虚拟交换机
- 1-5 类式组件
- ISO 13400(DoIP)标准解读
- Servlet运行原理_API详解_请求响应构造进阶之路(Servlet_2)
- leetcode 763. Partition Labels 划分字母区间(中等)
- Worthington RNA determination detailed introduction
- Where is the DP interface of desktop computer (what if the host has no DP interface)
猜你喜欢

VMware VCSA 7.0 Install

研发效能的道法术器

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

Tyrosine decarboxylase -- characteristics of tyrosine decarboxylase of Streptococcus faecalis in Worthington

Leetcode59. Spiral matrix II

以JSP为视图解析器搭建SSM项目

SAP temporary tablespace error handling

连接池-归还连接详解(下)

【TA-霜狼_may-《百人计划》】图形3.6 纹理压缩——包体瘦身术

JS高级 之 ES6~ES13 新特性
随机推荐
研发效能的道法术器
VS2005透过SourceOffSite访问VSS2005的设置方法「建议收藏」
PIP image download
CMake 基础学习
【C】喝汽水,找单身狗问题
VMware VCSA 7.0 Install
Use pytoch to quickly train the network model
PMP Exam countdown, look at 3A pass bag!
After SAP Oracle replicates a new instance, the remote connection of the database reports an error ora-01031
EN 1873屋面用装配附件.塑料单个屋面灯—CE认证
1-6 state and binding events
centos7安装mysql8
PowerCLi VMware vCenter 通过自建的PXE Server一键批量部署常规New-VM
Do you know any formal part-time platforms?
通配符 SSL/TLS 证书
Machine learning problem notes
Have passed hcip and joined the company of your choice, and share the learning experience and experience of Huawei certification
Jincang database kingbasees client programming interface guide ODBC (2. Overview)
Hutool official website (is hutool easy to use)
ISO 13400(DoIP)标准解读