I have a query that makes a calculation, plus the field "a.costarticles" appears with value zero at times, then it generates a division error by zero, is it possible to pass some default value? Type 1 if it has a value of zero?
select a.totalcustoprodutos, a.datanota, a.numeronota, a.cfop,
((a.totalnota / a.totalcustoprodutos) - 1.000) * 100 as TotalMargem
from TB_C_VENDAS a
where a.numeronota > 0 and a.tipooperacao = 'V'