Reputation: 729
Iam trying to calculate percentage. The scenario is:
There is a field po_value. There is another field amt_paid
po_value is the total amount to be paid and amt_paid is the amount paid. Now i need to calculate the percentage paid. I tried the below query. But its wrong.
select concat(round((( po_value / amt_paid) * 100 ),2), '%') AS percentage from Table;
Upvotes: 2
Views: 38
Reputation: 7695
You have to do it in reverse manner:
select concat(round((( amt_paid / po_value) * 100 ),2), '%') AS percentage from Table;
It's simple rule how percentage is calculated - you divide what is payed by max value and that's ratio, finally multiplying it with 100
Upvotes: 2