CleverCode最近在導出報表的時候,在整數做減法的時候,發現整數減去null得到是null。這是一個細節問題,希望大家以後注意。
select id, total, used, (total - used) as have from test_table
select id, ifnull(total,0) as total, ifnull(used,0) as used, (ifnull(total,0) - ifnull(used,0)) as have from test_table