I just came across a query I had around from some analysis I was doing some months ago. I've most of these queries stored in Org-Mode documents in code blocks which I can run inside the document (and get the results right next to the code block).

The query is analyzing the skill demand on UpWork. Job ads can be tagged with multiple skills so the counts below have overlap (for example, there are many jobs tagged with both php and wordpress).

 1: SELECT
 2: rank() over (order by JS.jobs_count desc) as rank,
 3: ROUND( (JS.jobs_count::float / T.total::float)::numeric * 100.0::numeric , 2) AS percentage,
 4: S.skill_name,
 5: JS.jobs_count
 6: FROM (
 7:     SELECT
 8:     skill_id,
 9:     COUNT(*) as jobs_count
10:     FROM odesk_job_skill
11:     GROUP BY skill_id
12:     ORDER BY jobs_count DESC
13: ) JS
14: JOIN odesk_skill S ON JS.skill_id = S.id
15: JOIN ( SELECT count(*) AS total FROM odesk_job ) T ON 1=1
16: WHERE JS.jobs_count > 1
17: LIMIT 30;

Another way to do this would be to normalize by the sum of the job counts. The proportions are the same as before, the only difference is that now the percentages add up to 100.

 1: WITH R AS (
 2:     -- count jobs tagged with each skill
 3:     SELECT
 4:     JS.jobs_count ,
 5:     S.skill_name
 6:     FROM (
 7:         SELECT
 8:         skill_id,
 9:         COUNT(*) as jobs_count
10:         FROM odesk_job_skill
11:         GROUP BY skill_id
12:         ORDER BY jobs_count DESC
13:     ) JS
14:     JOIN odesk_skill S ON JS.skill_id = S.id
15:     JOIN ( SELECT count(*) AS total FROM odesk_job ) T ON 1=1
16:     WHERE JS.jobs_count > 1
17: ), T AS (
18:     -- add up all the job counts for each skill
19:     SELECT SUM(jobs_count)::float AS total FROM R
20: )
21: SELECT
22: rank() over (order by R.jobs_count desc) as rank,
23: -- normalize skill counts
24: ROUND( (R.jobs_count::float / T.total)::numeric * 100.0::numeric , 2) AS percentage,
25: R.skill_name
26: FROM R,T
27: LIMIT 30;

And here's a small plot of the skills made with Python and pandas

 1: #!/usr/bin/python
 2: import pandas as pd
 3: import matplotlib.pyplot as plt
 4: import numpy as np
 5: from matplotlib import cm
 6: pd.options.display.mpl_style = 'default'
 7: l = 30
 8: 
 9: x = []
10: y = []
11: for z in data[:l]:
12:     x.append(float(z[1]))
13:     y.append(z[2])
14: 
15: df = pd.DataFrame({'skills': y, 'counts': x })
16: df.set_index('skills')
17: af = df.plot(kind='bar', legend=False, title='', x='skills', figsize=(15, 7), color='rgbymc')
18: plt.savefig('./skill-demand-graph.png', bbox_inches='tight')