IF
(expr1,expr2,expr3)
expr1: 判断条件
如果为真,取值expr2
否则取expr3
SELECT
...
IF (
INVALID = 0,
IF(INVOICE_TYPE IN (0, 1, 4, 5), (CARGO_AMOUNT_DISCOUNT / (1 + CARGO_TAX_RATE)), CARGO_PRICE_DISCOUNT),
0
) CARGO_PRICE_DISCOUNT,
IF (
INVALID = 0,
IF(INVOICE_TYPE IN (0, 1, 4, 5), CARGO_AMOUNT_DISCOUNT - CARGO_AMOUNT_DISCOUNT / (1 + CARGO_TAX_RATE), CARGO_TAX_DISCOUNT),
0
) CARGO_TAX_DISCOUNT,
...
FROM
your_table
WHERE
ID = 88