在打印出一些涉及除以计算百分比的计算值时,我收到了除以零的错误。我不担心它正在发生,我只想知道如何打印 0 以及该行的其余部分,而不是打印错误,即 0%。
这是我的打印声明:
print cast(@usercode as varchar) + ' ' + @username + space(4) +
'cr' + space(4) + cast(@totalUserVolumeCredit as varchar) +
space(4) + cast(@userUnpaids as varchar) + space(4) +
cast(@userDisputes as varchar) + space(4) +
cast((@userUnpaids + @userDisputes) as varchar) + space(4) +
cast(((@userUnpaids + @userDisputes)/@totalUserVolumeCredit) as varchar) + --error line
space(4) + cast(@userRedirectsVolume as varchar);