【发布时间】:2015-02-15 03:44:33
【问题描述】:
我在 pentaho 仪表板中添加了一个提示。我想在该提示中添加“ALL”类别,这意味着当我选择“ALL”时,它不应该过滤数据,它应该获取所选类别下的所有数据。大家能帮帮我吗?
【问题讨论】:
标签: pentaho pentaho-cde
我在 pentaho 仪表板中添加了一个提示。我想在该提示中添加“ALL”类别,这意味着当我选择“ALL”时,它不应该过滤数据,它应该获取所选类别下的所有数据。大家能帮帮我吗?
【问题讨论】:
标签: pentaho pentaho-cde
为此,使用类型 SQL 列表和“全部”作为值(注意区分大小写)。一个示例查询是:
SELECT DISTINCT 'All' AS VAL, 'ALL TERRITORIES' AS DESC FROM customer_w_ter
UNION ALL
select DISTINCT TERRITORY, TERRITORY from customer_w_ter
【讨论】:
@迈克尔克里斯托弗
我使用以下 postgresql 查询来获取数据。
select 'All' as accountclass
,status
,count(guaccountid) as count
from sms_accountinformation
group by status
union
select distinct accountclass
,status
,count(guaccountid)as count
from sms_accountinformation
group by accountclass,status
order by accountclass,status
有没有没有硬编码的替代方案?
数据集如下
"All";"Active";2288
"All";"PD";257
"All";"TD";777
"Customer";"Active";2275
"Customer";"PD";152
"Customer";"TD";359
"Dealer";"Active";13
"Dealer";"PD";105
"Dealer";"TD";418
【讨论】:
您需要在查询中添加一个包含“ALL”数据的额外行。在为 ALL 部分编写查询时,不需要执行 group by 子句。检查下面的代码(希望它会更清楚):
select distinct
accountclass,
status,
count(guaccountid)as count
from sms_accountinformation
group by accountclass,status order by accountclass,status
union
select 'ALL' as accountclass,
'ALL' as status,
'ALL' as count
from sms_accountinformation
这将为您获取一个带有“ALL”的结果集作为另一行,您可以在过滤器列表中使用它。
希望对你有帮助:)
【讨论】: