SELECt id, IF(type = 'P', amount, amount * -1) as amountFROM report
参见http://dev.mysql.com/doc/refman/5.0/en/control-flow-
functions.html。
此外,您可以处理条件为null的情况。如果为零:
SELECt id, IF(type = 'P', IFNULL(amount,0), IFNULL(amount,0) * -1) as amountFROM report
该部分
IFNULL(amount,0)表示 当金额不为null时返回金额,否则返回0 。



