Calculate Percentage Between Two Columns In SQL Query As Another Column
Answer :
Try this:
SELECT availablePlaces, capacity, ROUND(availablePlaces * 100.0 / capacity, 1) AS Percent FROM mytable
You have to multiply by 100.0 instead of 100, so as to avoid integer division. Also, you have to use ROUND
to round to the first decimal digit.
Demo here
Comments
Post a Comment