Skip to content

Instantly share code, notes, and snippets.

@meau
Last active November 12, 2018 16:13
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 meau/acdd42b29d726daa47e70b6133bd0559 to your computer and use it in GitHub Desktop.
Save meau/acdd42b29d726daa47e70b6133bd0559 to your computer and use it in GitHub Desktop.
SELECT
COUNT(DISTINCT accession.id)
FROM
accession
JOIN
linked_agents_rlshp ON linked_agents_rlshp.accession_id = accession.id
LEFT JOIN
agent_person ON linked_agents_rlshp.agent_person_id = agent_person.id
LEFT JOIN
agent_corporate_entity ON linked_agents_rlshp.agent_corporate_entity_id = agent_corporate_entity.id
LEFT JOIN
name_person ON name_person.agent_person_id = agent_person.id
LEFT JOIN
name_corporate_entity ON name_corporate_entity.agent_corporate_entity_id = agent_corporate_entity.id
LEFT JOIN
enumeration_value evrole ON linked_agents_rlshp.role_id = evrole.id
WHERE
evrole.value = 'source';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment