How do I get SUM function in MySQL to return '0' if no values are found?

前端 未结 4 658
萌比男神i
萌比男神i 2020-11-29 18:07

Say I have a simple function in MySQL:

SELECT SUM(Column_1)
FROM Table
WHERE Column_2 = \'Test\'

If no entries in Column_2 con

4条回答
  •  星月不相逢
    2020-11-29 18:27

    if sum of column is 0 then display empty

    select if(sum(column)>0,sum(column),'')
    from table 
    

提交回复
热议问题