我需要“订单数量”的累计金额。
当我将此代码与选择字段一起使用为“Sales_Year”、“Sales_Billing_Date”、“Order_Qty”时,我得到了我需要的结果。
使用的代码:
"Sales_Year",
"Sales_Billing_Date",
"Order_Qty" ,
SUM ("Order_Qty") OVER ( ORDER BY "Sales_Billing_Date") AS "SUM_VAL"
FROM
( SELECT
"Sales_Year",
"Sales_Billing_Date" ,
SUM("Order_Qty") AS "Order_Qty" FROM "PS_WARRANTY_ANALYTICS"."PS_PAL_DLR_SALES"
GROUP BY "Sales_Year","Sales_Billing_Date"
)
但是我选择了更多字段(添加了“Equipment_ID”),它没有被分组为它的唯一字段。如何实现包含此字段代码的累积值
"Equipment_ID"
SELECT
"Sales_Year",
"Sales_Billing_Date",
"Equipment_ID",
"Order_Qty" ,
SUM ("Order_Qty") OVER ( ORDER BY "Sales_Billing_Date") AS "SUM_VAL"
FROM
( SELECT
"Sales_Year",
"Sales_Billing_Date" ,
"Equipment_ID",
SUM("Order_Qty") AS "Order_Qty" FROM "PS_WARRANTY_ANALYTICS"."PS_PAL_DLR_SALES"
GROUP BY "Sales_Year","Sales_Billing_Date","Equipment_ID"
)
累计:
没有累积: