我有以下查询,但我想在此之前的一周内提取这些数据。有没有办法在不引用今天或集合datestamp
的情况下设置点到点之间的范围?
SELECT
Count(orders.id) AS order_count
FROM
orders
WHERE
orders.requested_delivery_date between CURRENT_DATE - INTERVAL '7 days' and now()
答案 0 :(得分:0)
select count(orders.id) as order_count
from orders
where
date_trunc('week', requested_delivery_date) =
date_trunc('week', current_date - interval '7 days')