对于以下查询,我需要一些专业知识帮助。所以,我需要根据 GMV 金额每天进行累计计算。
我最大的问题是我无法从 GROUP BY 中删除 gmv,否则会出现一些错误。
关于如何解决这个问题的任何想法?
SELECT CONVERT(varchar, order_date, 103) AS date,
DATEPART(WEEKDAY, order_date) AS weekday,
SUM(gmv) OVER (ORDER BY order_date ROWS UNBOUNDED PRECEDING) AS cumulative
FROM database
WHERE order_date BETWEEN '2017-02-01' AND '2017-08-01'
GROUP BY order_date,
gmv;