将多行合并为单行
是否可以将多个行值连接到单行?我从中获取数据的存储过程返回多个几乎相同的行,除了已分配多个类别的产品的“类别”列有所不同之外。我想将这些类别合并到一列中,并用新行分隔。示例数据:
Name Article number Sales Sales Category
------------------------------------------------
Product 1 2059102-1 20520 Retailer 1
------------------------------------------------
Product 1 2059102-1 20520 Retailer 2
------------------------------------------------
Product 1 2059102-1 20520 Retailer 3
------------------------------------------------
Product 2 2059102-2 2050 Retailer 1
------------------------------------------------
Product 2 2059102-2 5302 Retailer 3
期望的结果:
Name Article number Sales Sales Category
------------------------------------------------
Product 1 2059102-1 20520 Retailer 1
Retailer 2
Retailer 3
------------------------------------------------
Product 2 2059102-2 2050 Retailer 1
Retailer 3
谢谢!
Is it possible to join multiple row values to a single row? The stored procedure from where I acquire the data that I use return multiple, almost identical rows except that the category-column dfferentiates for products that have been assigned multiple categories. I would like to consolidate these categories to one column, separated by new lines. Example data:
Name Article number Sales Sales Category
------------------------------------------------
Product 1 2059102-1 20520 Retailer 1
------------------------------------------------
Product 1 2059102-1 20520 Retailer 2
------------------------------------------------
Product 1 2059102-1 20520 Retailer 3
------------------------------------------------
Product 2 2059102-2 2050 Retailer 1
------------------------------------------------
Product 2 2059102-2 5302 Retailer 3
Desired result:
Name Article number Sales Sales Category
------------------------------------------------
Product 1 2059102-1 20520 Retailer 1
Retailer 2
Retailer 3
------------------------------------------------
Product 2 2059102-2 2050 Retailer 1
Retailer 3
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个 RDL 表,并使用两个 分组表达式在表的详细信息部分设置分组(这样您在表详细信息中就有一个分组,但具有多个分组表达式)。每个字段的分组表达式应该是一个:名称、文章编号。
然后在 RDL 表中为每个字段(名称、商品编号、销售额、销售类别)放置一列。诀窍是在销售类别单元格中放置一个列表控件。在列表中为“销售类别”字段添加一个文本框,我想您会得到您想要的结果。
还有一些令人讨厌的 SQL “行连接”的技巧,但恕我直言,这不太容易维护。
Create an RDL table and setup a Grouping on the Detail section of the table with two grouping expressions (so you have a single Grouping in the Table Details, but with multiple grouping expressions). The grouping expressions should be one for each of the fields: Name, Article number.
Then put a column in the RDL table for each field (Name, Article number, Sales, Sales Category). The trick is putting a List control in the Sales Category cell. In the list add a textbox for the "Sales Category" field and I think you'll get the result you want.
There is also some nasty SQL tricks for "row concatenation", but that is not very maintainable IMHO.