I am struggling with MySql SUM() function . For example , I have a table called my_table with columns('id','price_1','price_2') . I know this table is not following 1st normalization . But I need to just to demonstrate what I am in need . I want to select like this .
SELECT SUM({price_1 if price_2 is null}) GROUP BY `id`
How can I achieve this?
price_2from only those rows whereprice_1is null or whether you need to have sum of from all rows so thatprice_1is used unlessprice_2is non-null, in which case it is to be included in sum?