Home > Article > Daily Programming > How to find percentage in mysql
Finding percentages in MySQL: Determine the numerator and denominator. Divide the numerator by the denominator to find the result. Use the ROUND() function to round the result to a specified number of decimal places (usually two decimal places). Syntax: ROUND((numerator/denominator) * 100, 2)
##How to find the percentage in MySQL
In MySQL, you can use theROUND() function and the division operator (
/) to calculate percentages.
Steps:
function to round the result to a specified number of decimal places, usually two decimal places.
Syntax:
<code class="mysql">ROUND((分子 / 分母) * 100, 2)</code>
Example:
Calculate the order total of $100, one of which The price of an item is $20. How to find the percentage of the total amount that this item accounts for?<code class="mysql">ROUND((20 / 100) * 100, 2)</code>Result: 20.00 Therefore, this item accounts for 20% of the total.
The above is the detailed content of How to find percentage in mysql. For more information, please follow other related articles on the PHP Chinese website!