if condition in mysql for column sum code example Example: mysql sum with if SELECT SUM(IF( `column` = 1, `column`, 0)) as total