Percentages
Multiply by 100.0 to avoid integer division and ROUND the result.
Example
SELECT country, ROUND(100.0 * COUNT(*) / (SELECT COUNT(*) FROM students), 1) AS pct
FROM students GROUP BY country;Result
country | pct Ghana | 25.0 Kenya | 12.5 Nigeria | 50.0 South Africa | 12.5
Exercise
Avoid integer division.
100. * a / b
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.