$sql = "UPDATE purchase SET stat='1' WHERE `id`='$id' AND 4*(plan)<= sum(plan) ";
Or
$sql = "UPDATE purchase SET stat='1' WHERE `id`='$id' AND 4*(plan-1)<= sum(plan-1) ";
I am trying to make a query by this update, if summation of all row is grater than 1st row, it will update 1st row, and this rules for all row. But it is showing error and says
Error updating record: Invalid use of group function
What is the problem in this query? I need help for this error.