This is the query I am using to get the percentage per country for participants in events:
SELECT count(p.id) as count, round(100*count(p.id)/(SELECT count(p.id) FROM participants as p),1) as percentage, p.Nationality
FROM participants as p
JOIN participants_events as pe on p.id = pe.participant_id
GROUP BY p.Nationality
Which returns a table like this:
+-------+------------+-------------+
| count | percentage | Nationality |
+-------+------------+-------------+
| 100 | 0.8 | Albania |
| 114 | 0.9 | Algeria |
| 273 | 2.2 | Belgium |
| ... | ... | ... |
+-------+------------+-------------+
I want to modify the query in order to don't show any rows with percentage less than 1% but summarize their number and add is as 'Other' with the new percentage. So with the new query the results will be:
+-------+------------+-------------+
| count | percentage | Nationality |
+-------+------------+-------------+
| 214 | 1.7 | Other |
| 273 | 2.2 | Belgium |
| ... | ... | ... |
+-------+------------+-------------+