我如何调整这个查询来显示之前的,比如 61 周?
select
to_char(order_date,'IYYY') as iso_year,
to_char(order_date,'IW') as iso_week,
sum(sale_amount)
from orders
where
to_char(order_date,'IW') <> to_char(SYSDATE) --exclude this week in progress
and to_char(order_date,'IYYY') = 2010
group by
to_char(order_date,'IYYY')
to_char(order_date,'IW')
我的第一直觉是做
where
to_char(order_date,'IW') <> to_char(SYSDATE) --exclude this week in progress
and to_char(order_date,'IYYY') >= to_char(order_date,'IW') - 61
我可以省略“2010”要求并将结果限制为 61 行吗?有没有更好的办法?
非常感谢任何为我指明正确方向的帮助!