不幸的是,我在本机date
查询中通过sql
进行过滤需要花费数小时的时间。有人具有丰富的元数据库经验吗?
select to_date("date", 'YYYYMMDD') AS Date,
round(sum("price"), 2) AS "Revenue"
from "cdw_transactions"
group by Date
WHERE Date = {{Date}}
答案 0 :(得分:0)
查询应重写为:
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
答案 1 :(得分:0)
您应该在group by
之前过滤 。但是,group by
并没有实际需要,因为您只想返回一行。
我认为是这样的:
select {{Date}} AS Date,
round(sum("price"), 2) AS "Revenue"
from "cdw_transactions"
where to_date("date", 'YYYYMMDD') = {{Date}};