能約1幫助我與SQL紅移查詢,得到的結果如下SQL紅移選擇查詢來獲取總銷售額遞減
3列
order_date的,daily_sale(發售THT一天進行)中提到的方式,total_sale (total_sale直到日期) order_date daily_sale total_sale 2017-01-31 1830 206316.4 2017-01-30 2487.5 206316.4 2017-01-29 5456 206316.4 2017-01-28 2786.2 206316.4 2017-01-27 2337 206316.4 2017-01-26 1404.2 206316.4
怎麼能以這樣的方式
order_date daily_sale total_sale 2017-01-31 1830 206316.4 2017-01-30 2487.5 204486.4 (206316.4 -1830) 2017-01-29 5456 201999.4 (206316.4 -1830-2487.5) and so on
非常感謝它的工作 但我們需要添加 '(SUM(daily_sale) OVER(ORDER BY order_date desc ROWS UNBOUNDED PRECEDING) ' 在內部查詢中,否則會引發錯誤 '具有ORDER BY子句的聚合窗口函數需要一個框架子句' 但仍thnx的解決方案 – ankitkhanduri
不客氣,我從來沒有使用'amazon-redshift',但我的查詢很好地工作SQL SERVER。很高興如果這對你有幫助 –