SQL: sum 3 columns when one column has a null value?

前端 未结 9 2077
北恋
北恋 2020-12-05 09:37
SELECT 
    sum(TotalHoursM)
          + (TotalHoursT)
          + (TotalHoursW)
          + (TotalHoursTH)
          + (TotalHoursF) 
          AS TOTAL
FROM LeaveR         


        
9条回答
  •  感动是毒
    2020-12-05 09:52

    Just for reference, the equivalent statement for MySQL is: IFNull(Column,0).

    This statement evaluates as the column value if not null, otherwise it is evaluated as 0.

提交回复
热议问题