I have 3 columns in my MySQL table type, sum and custom_sum where custom_sum can be empty, and i am stuck on modifying query
SELECT `type`, SUM(`sum`) FROM `localhost-test` GROUP BY `type`
What i need is to use sum in SUM() if custom_sum is empty, and use custom_sum if it is not.
Is it possible to sum by different columns based on "if" statement in mysql ?
SUM(ISNULL(custom_sum, `sum`))