Count links between graphs requires prebound graphs
SELECT
(COUNT(?target) AS ?lsc)
WHERE {
GRAPH ?graphName {
?subject a ?sourceType
}
GRAPH ?linkingGraphName {
?subject ?predicate ?target
}
GRAPH ?otherGraphName {
?target a ?targetType
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?graphName")
v6("?linkingGraphName")
v9("?lsc")
v8("?otherGraphName")
v4("?predicate")
v2("?sourceType")
v1("?subject")
v5("?target"):::projected
v7("?targetType")
v1 --"a"--> v2
v1 -->v4--> v5
v5 --"a"--> v7
bind1[/"count(?target)"/]
v5 --o bind1
bind1 --as--o v9