Hi folks,
I have a table with a country column. I need to do one query to get the percentage of each country in my table.
select
country,
((count(rowid)/total_rows)*100)
from my_table
group by country -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Try the following:
SELECT country, count(1)/(SELECT COUNT(*) FROM countries)*100.0 AS pct
FROM countries GROUP BY country -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --