sql-server - Concatenate string values in one row from multiple rows with constraints SSIS / SQL Server
问题描述
I need some help, I'm pretty new in SSIS and have some basics in SQL Server.
I have a SQL query within a package in SSIS, I tried various solutions (STUFF()
, STRING_AGG()
, SUBSTRING()
...), but every time I got some errors.
I have a file source with data that looks like this:
Name,Active,AccountNr,Comment
Alex,30,895478548,Food,
Alex,50,895478548,Sport,
Alex,30,5544440000,Travel,
Fabien,15,4555555,Car,
Fabien,2500,63553336,Family,
Fabien,2500,4555555,Health,
Alex,30,895478548,Travel
I want to add the actives
and concatenate string values of Comment
column (which have the same Account
number) in one row from multiple rows
For example, rows 4-6 have the same Account number, then we should get
:Fabien,2515,Family/health
as output.
解决方案
SSIS 不支持string_agg()
吗?如果是这样,您可以这样做:
select name, account_number, string_agg(comment, '/') all_comments
from mytable
group by name, account_number
推荐阅读
- vba - VBA - 将 PDF 作为字符串读取 - 有时不能,但有时可以 - “运行时错误 62”
- android - 有什么方法可以使用背景图像提高 xamarin.android ui 性能
- python - Jupyter Notebook - 数字分隔符
- python - 为 Django 管理员创建 JSONField 属性的动态过滤器类
- java - 无法关闭所有打开的 Windows
- python - 双循环优化
- arrays - 遍历多个结构数组的最简单方法?
- selenium - 无头网络浏览器是否需要 selenium WebDriver?
- java - 如何更新/订购“Android.mk”文件?
- php - imap_open():无法在核心 php 中打开流