我正在尝试从当前周而不是过去7天获取数据。我的疑问是:
select
order_datetime_tz::date AS date,
orders
FROM
order_fact f
where order_datetime_tz < current_date
and order_datetime_tz >= date_trunc('week',current_date) - interval '1 week'
然而,这让我回归过去7天.. 有什么想法吗?
谢谢!
答案 0 :(得分:2)
当前周的开头为date_trunc('week',current_date)
,因此您只想稍晚查询日期:
select
order_datetime_tz::date AS date,
orders
FROM
order_fact f
where order_datetime_tz >= date_trunc('week',current_date)