Skip to content

Instantly share code, notes, and snippets.

@mayhem
Created July 11, 2019 13:42
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 mayhem/9a2a6c964d53ac977d47bd11e8a8c912 to your computer and use it in GitHub Desktop.
Save mayhem/9a2a6c964d53ac977d47bd11e8a8c912 to your computer and use it in GitHub Desktop.
SELECT DISTINCT r.gid as recording_mbid, r.name as recording_name, ac.name as artist_credit_name, array_agg(a.gid) as artist_mbids
INTO recording_artist_credit_pairs
FROM recording r
JOIN artist_credit ac ON r.artist_credit = ac.id
JOIN artist_credit_name acn ON ac.id = acn.artist_credit
JOIN artist a ON acn.artist = a.id
GROUP BY r.gid, r.name, ac.name
ORDER BY r.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment