Skip to content

Instantly share code, notes, and snippets.

@mbklein
Created March 30, 2010 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbklein/349553 to your computer and use it in GitHub Desktop.
Save mbklein/349553 to your computer and use it in GitHub Desktop.
select 'flag:' || lower(sc.code) || ':' || sc.name,
d.downloads, (d.downloads/t.total)*100
from (select country_code,sum(relative_value) as downloads from stats.download_country_month
where year=?
group by country_code) as d,
stats.country sc,
(select sum(relative_value::real) as total from stats.download_month
where year=?) as t
where d.country_code = sc.code
order by d.downloads desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment