当前位置:网站首页>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 ~~~
边栏推荐
- Oracle创建表空间和用户
- 1-7 解决类中方法的this指向问题
- EN 12101-8:2011 smoke dampers for smoke and heat control systems - CE certification
- 1-7 solve the problem of this pointing of methods in classes
- How NAT configures address translation
- Summary of wrong questions of software designers
- VS2005透过SourceOffSite访问VSS2005的设置方法「建议收藏」
- pycharm配置运行环境
- VS2005 accesses the setting method "recommended collection" of vss2005 through sourceoffsite
- 实时数仓:美团点评Flink的实时数仓应用分享
猜你喜欢

Doip communication of canoe application case

Is the declarative code of compose so concise?

[TA frost wolf _may- "hundred people plan"] art 2.2 model basis

ZABBIX 5.0 uses its own redis template for monitoring

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

NAT如何配置地址转换

【C】替换空格,宏实现整数的二进制奇偶位交换

[TA frost wolf \u may - "hundred people plan"] Figure 3.6 texture compression - inclusion slimming

Leetcode59. 螺旋矩阵 II

Uricase - Characteristics of uricase in Worthington pig liver:
随机推荐
Powercl batch creates and manages virtual switches
E-commerce data model design
数仓:Doris在美团的应用实践
多传感器融合定位(一)——3D激光里程计
EN 1873屋面用装配附件.塑料单个屋面灯—CE认证
Multisensor fusion positioning (III) -- inertial technology
PowerCLi 批量添加esxi到vCenter
What do you need to bring with you for the NPDP exam? Stationery carrying instructions
请简述list,set,map类型的集合的各自特点(简述三种不同的继承方式下)
Tyrosine decarboxylase -- characteristics of tyrosine decarboxylase of Streptococcus faecalis in Worthington
Doip test development practice
pip镜像下载
[TA frost wolf \u may - "hundred people plan"] Figure 3.6 texture compression - inclusion slimming
VMware VCSA 7.0 Install
Leetcode59. 螺旋矩阵 II
【C】 Reverse string (two recursive ideas)
DevOps在物联网解决方案中的应用
With the help of rpa+lcap, the enterprise treasurer management can be upgraded digitally
fastdfs工作原理(技术原理)
多传感器融合定位(三)——惯性技术