51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

【SQL 技巧】营销数据如何用 DataEase 做累计数据查看

假设有如下一份营销数据,如果想在 DataEase 计算月累计,应该怎么办呢?

其实可以通过 SQL 数据集来进行实现,非常简单,SQL 语句如下。

| select month '月份', sales '销售额', ( select sum(sales) from monthlysales ms where ms.month <= m.month) '月累计销售额', cost '成本', ( select sum(cost) from monthlysales ms where ms.month <= m.month) '月累计成本', profit '利润', ( select sum(profit) from monthlysales ms where ms.month <= m.month) '月累计利润', order_num '订单数', ( select sum(order_num) from monthlysales ms where ms.month <= m.month) '月累计订单数', quantity '产品数', ( select sum(quantity) from monthlysales ms where ms.month <= m.month) '月累计产品数' from monthlysales m order by m.month; | |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|


展示结果如下:


赞(0)
未经允许不得转载:工具盒子 » 【SQL 技巧】营销数据如何用 DataEase 做累计数据查看