在上面的图像中,我有4列,我试图通过将它除以totalNumber来获得临界值和优先级的平均值。但由于某种原因我的查询不起作用,我也试图在除法后得到一个小数位
我的SQL查询:
$command1 = "UPDATE rating SET criticality = criticality + '$c' / totalNumber , Priority = Priority + '$p' / totalNumber, totalNumber = totalNumber + '$counter' WHERE no = '$id'";
答案 0 :(得分:1)
尝试在分割后将cast(round(criticality/totalNumber,1) as numeric(36,1))
用于小数点后一位。
$command1 = "UPDATE rating SET criticality = cast(round(criticality/totalNumber,1) as numeric(36,1)) , Priority = cast(round(Priority /totalNumber,1) as numeric(36,1)) , totalNumber = totalNumber + '$counter' WHERE no = '$id'";