我刚刚接触SQL,需要帮忙。在我的SELECT语句中,以下内容出现了除以零的错误:
SUM(Cast((replace(replace(replace (p.[Total Sales], '$', ''), '(','-'), ')','')) as money)) - SUM(Cast((replace(replace(replace (p.[Total Cost], '$', ''), '(','-'), ')','')) as money)) / SUM(Cast((replace(replace(replace (p.[Total Sales], '$', ''), '(','-'), ')','')) as money)) as new_bal
我知道需要使用CASE语句,但不确定如何应用。