我有一个视图,它根据PARTITION BY
子句计算前一行的值的滚动总和,我需要指出PARTITION BY
子句中的一个字段可以有空值。
sum(s."QuantityChange") OVER (PARTITION BY s."LocationId", s."PartId", s."SupplierFacilityId" ORDER BY s."DueDate" ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS "RunningSum"
有时SupplierFacilityId
为空,这很好,它仍应包含在sum()
计算中。
Postgres可以做到这一点吗?