如何在reportviewer中将两个组连接到一个组 [英] How to join two group to one in reportviewer
问题描述
我有一个a,b,c和d的数据分组。在某些情况下,我想打印使用reportviewer,将a和c分组到一个组,b和d分组到一个组。有没有办法做到这一点?
说字段名='product_type',里面是类型a,类型b,类型c和类型d。
通常在进行分组时,使用'group by product_type',因此它会在一个组中显示所有类型a,在一个组中键入b等等。
但是现在是什么我想要的是,类型a和类型c下的所有产品都是一组中的组,所以键入b并键入d。
至少有两种方法可以实现但是,最好的选择是使用正确的SELECT
语句,如下所示:
DECLARE @ tmp 表(product_type VARCHAR ( 5 ))
INSERT INTO @ tmp (product_type)
VALUES (' a'),(' a'),(' a'),
(' b'), (' b'),(' c'),
(' c' ),(' c'),(' c'),
(' d'),(' d'),(' d')
SELECT product_type, CASE WHEN product_type = ' c' 那么 ' a'
WHEN product_type = ' d ' 那么 ' b'
ELSE product_type END AS product_type1
FROM @ tmp
ORDER BY product_type1
结果:
product_type product_type1
a a
a a
a a
c a
c a
c a
c a
d b
d b
d b
b b
b b
它?
另一种方法是添加公式字段 [ ^ ]与SQL语句的作用相同。
= IIf(Fields!product_type.Value = < span class =code-string> c, a,IIF(Fields!product_type.Value = d, c,Fields!product_type.Value))< br $> b $ b
要获取有关在ReportViewer中对数据进行分组的信息,请参阅:在ReportViewer报告中对数据进行分组 [ ^ ]
请在下面找到链接可能会有所帮助。通常在reportviewer上有分组元素的选项,你可以在那里指定datasetName.ColumnName以获取更多详细信息
https://msdn.microsoft.com/en-us/library / ms251700(v = VS.80)的.aspx
I have a some data grouping by a, b, c, and d. In some condition, i want to print use reportviewer, by grouping a and c to one group and b and d to one group. Is that any way to do this?
Say field name='product_type', inside it is type a, type b, type c and type d.
Normally when do grouping, is use 'Group by product_type', so it will display all the type a in one group, type b in one group and etc.
But now what i want is, all the product under type a and type c is group in one group, and so type b and type d.
There's at least two ways to achieve that, but the best option is to use properSELECT
statement, as is shown below:
DECLARE @tmp TABLE(product_type VARCHAR(5)) INSERT INTO @tmp (product_type) VALUES('a'), ('a'), ('a'), ('b'), ('b'), ('c'), ('c'), ('c'), ('c'), ('d'), ('d'), ('d') SELECT product_type, CASE WHEN product_type = 'c' THEN 'a' WHEN product_type = 'd' THEN 'b' ELSE product_type END AS product_type1 FROM @tmp ORDER BY product_type1
Result:
product_type product_type1 a a a a a a c a c a c a c a d b d b d b b b b b
Got it?
Another way is to add formula field[^] which will do the same as SQL statement.
=IIf(Fields!product_type.Value ="c", "a", IIF( Fields!product_type.Value ="d","c", Fields!product_type.Value))
To get information about grouping data in ReportViewer, please see this: Grouping Data in a ReportViewer Report[^]
Please find below link might be helpful. generally on reportviewer there is option of grouping element you can specify there datasetName.ColumnName for more details
https://msdn.microsoft.com/en-us/library/ms251700(v=vs.80).aspx
这篇关于如何在reportviewer中将两个组连接到一个组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!