在元数据库仪表板中按日期过滤不
Posted
技术标签:
【中文标题】在元数据库仪表板中按日期过滤不【英文标题】:Filtering by Date in Metabase Dashboard doesn't 【发布时间】:2019-06-16 16:50:44 【问题描述】:不幸的是,我在原生 sql
查询中通过 date
过滤而苦苦挣扎了好几个小时。有人有深厚的元数据库经验吗?
select to_date("date", 'YYYYMMDD') AS Date,
round(sum("price"), 2) AS "Revenue"
from "cdw_transactions"
group by Date
WHERE Date = Date
【问题讨论】:
【参考方案1】:查询应改写为:
select to_date("date", 'YYYYMMDD') AS "Date",
round(sum("price"), 2) AS "Revenue"
from "cdw_transactions"
where "date" = Date -- where before grouping
group by to_date("date", 'YYYYMMDD'); -- matching select
【讨论】:
【参考方案2】:您应该在group by
之前过滤。但是,实际上不需要 group by
,因为您只想返回一行。
我认为是这样的:
select Date AS Date,
round(sum("price"), 2) AS "Revenue"
from "cdw_transactions"
where to_date("date", 'YYYYMMDD') = Date;
【讨论】:
以上是关于在元数据库仪表板中按日期过滤不的主要内容,如果未能解决你的问题,请参考以下文章