假设这个查询,
SELECT
SUM (Quantity) OVER (Partition By Symbol ORDER BY PositionID ASC ROWS UNBOUNDED PRECEDING) as RemainedQty
是否可以在窗口函数中定义条件?在此示例中,我需要在每一行中获取不同情况下的 SUM(数量)。一些东西(假设)像:
SELECT
SUM (Quantity) OVER (Partition By ...) Where SomeColumn='X' as RemainedQty_X,
SUM (Quantity) OVER (Partition By ...) Where SomeColumn='Y' as RemainedQty_Y ...