所以我有下面的代码
SELECT PICK_SO_NUMBER, CUSTOMER, SO_PRODUCT, DO_QUANTITY, DO_PACKING, DO_DATE,
COALESCE(INVOICED_QTY, 0) AS INVOICED_QTY,
DO_QUANTITY-INVOICED_QTY AS NOT_INVOICED,
INVOICE_PACKING
FROM VW_TRAFFIC_PO_SIDE
WHERE DO_QUANTITY > INVOICED_QTY OR (INVOICED_QTY IS NULL AND DO_QUANTITY IS NOT NULL)
合并下面的行,假设从 INVOICED_QTY 中减去 DO_QUANTITY,但是当 INVOICED_QTY 为 NULL 时,它不再减去 0,而是减去 null,因此新列返回 null,其中 INVOICED_QTY 为 null
我尝试了多种方法:尝试合并到一个案例,将合并写为 INVOICED,然后在减法表达式中使用 INVOICED,我尝试在减法的同一行中使用合并(中间没有逗号,我觉得这是解决方案效果最好,但无法编译)