【发布时间】:2016-04-18 08:51:56
【问题描述】:
我正在使用 jaspersoft studio 6.2。我在汇总带中放置了一个条形图,如何将其设置为对值表达式中的某些字段进行计数? 例如
我有这个查询/数据集:
select 'xx' as UsageDate, 'a' as ProductName, 1 as CustomerKey
union all select 'xx' as UsageDate, 'b' as ProductName, 1 as CustomerKey
union all select 'xx' as UsageDate, 'a' as ProductName, 2 as CustomerKey
union all select 'yy'as UsageDate, 'a' as ProductName, 1 as CustomerKey
union all select 'yy' as UsageDate, 'b' as ProductName, 3 as CustomerKey
我想要达到的是
select usagedate, productname, count(distinct customerkey) as val from (
select 'xx' as UsageDate, 'a' as ProductName, 1 as CustomerKey
union all select 'xx' as UsageDate, 'b' as ProductName, 1 as CustomerKey
union all select 'xx' as UsageDate, 'a' as ProductName, 2 as CustomerKey
union all select 'yy'as UsageDate, 'a' as ProductName, 1 as CustomerKey
union all select 'yy' as UsageDate, 'b' as ProductName, 3 as CustomerKey
) as t
group by usagedate, productname
usagedate 是类别,productname 是系列。如何将图表中的值设置为count(distinct customerkey)?我知道我可以使用第二个查询作为数据集,并将 val 字段设置为图表中的值,但我还需要在报告中显示详细信息,因此更喜欢只使用 one 查询/数据集来执行此操作全部。
这可能吗?
【问题讨论】:
标签: java jasper-reports