# Statistics about secondary organisations in org:Membership instances.
#
# Total with secondary organisation:              1222
# Secondary differs from primary:                  736
# Secondary equals primary:                        230
# Secondary exists but no primary:                 256

PREFIX tm: <https://daniel.degu.cl/ontologies/theatre-migrants/>
PREFIX org: <http://www.w3.org/ns/org#>

# Count memberships with a secondary organisation
SELECT (COUNT(*) AS ?total_with_secondary) WHERE {
  ?s a org:Membership .
  ?s tm:secondaryOrganisation ?o .
}
;
# Count where secondary differs from primary
SELECT (COUNT(*) AS ?secondary_differs) WHERE {
  ?s a org:Membership .
  ?s org:organization ?primary .
  ?s tm:secondaryOrganisation ?secondary .
  FILTER(?primary != ?secondary)
}
;
# Count where secondary equals primary
SELECT (COUNT(*) AS ?secondary_equals_primary) WHERE {
  ?s a org:Membership .
  ?s org:organization ?primary .
  ?s tm:secondaryOrganisation ?secondary .
  FILTER(?primary = ?secondary)
}
;
# Count with secondary but no primary
SELECT (COUNT(*) AS ?secondary_no_primary) WHERE {
  ?s a org:Membership .
  ?s tm:secondaryOrganisation ?secondary .
  FILTER NOT EXISTS { ?s org:organization ?primary }
}
