It's usually better to do multiplication before division.You need to check for a divide by zero.Also, float may not be the ideal datatype for this. For most business applications, it is better to use a datatype with an set precision and an exact representation in base 10.update #temp_testing_percentageset [percent] = case when amount = 0 then null else ( 100.0 * amount ) / total end
Example with a decimal datatype:update #temp_testing_percentageset [percent] = case when amount = 0 then null else convert(decimal(10,2),round(( 100.0 * amount ) / total,2)) end
CODO ERGO SUM