语法如下: //求和: 计算出记录集中 paystatus=1 的 paycost 的和。 SELECT sum(IF(`paystatus`=1,`paycost`,0))as a FROM `table`