我的数据以这种格式存储:
Name | Order Date | Order Amount
---
我需要显示它,例如:
Name | Jun 16-30 | Jul | Aug | Sep | Oct | ... | May | Jun 1 - 15
---
每个日期范围/月份下的订单金额总和。
有没有办法通过枢轴来实现这一目标,或者通过案例来求和?我需要总结日期/月份在日期之间的位置,但是年份并不重要。
在MS Access中使用条件聚合的一般格式为:
select name,
sum(iif(datepart("month", OrderDate) 6 and datepart("day", OrderDate) between 16 and 30, OrderAmount, 0)) as [Jun 16-30],
sum(iif(datepart("month", OrderDate) = 7, OrderAmount, 0) as [Jul],
. . .
from t
group by name;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句