Skip to content

Instantly share code, notes, and snippets.

@GaretJax
Created May 18, 2014 16:16
Show Gist options
  • Select an option

  • Save GaretJax/1eb9b73d37e8dc6203fd to your computer and use it in GitHub Desktop.

Select an option

Save GaretJax/1eb9b73d37e8dc6203fd to your computer and use it in GitHub Desktop.
select p.id as publication, count(distinct a.id) as authors, i.country, p.year
from affiliated_author as a
join publication as p on p.id = a.publication_id
join institution as i on i.id = a.institution_id
where a.publication_id in (
-- Publications with any author from Kuwait published on or before 2005
select distinct p.id
from publication as p
join affiliated_author as a on a.publication_id = p.id
join institution as i on a.institution_id = i.id
where i.country = 'Kuwait' and p.year <= 2005
)
group by i.country, p.id, p.year
order by p.year;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment