以下查询正在运行:
SELECT ?goal (count(?ngo) as ?ngoCount)
WHERE {?ngo a ngo:NGORecipient;
ngo:hasSDGGoal ?goal.
?goal rdfs:label ?sdglabel.}
GROUP BY ?goal
ORDER BY ?ngoCount
但是,当我去获取标签而不是 IRI 时,如下所示
SELECT ?sdglabel (count(?ngo) as ?ngoCount)
WHERE {?ngo a ngo:NGORecipient;
ngo:hasSDGGoal ?goal.
?goal rdfs:label ?sdglabel.}
GROUP BY ?goal
ORDER BY ?ngoCount
我收到错误:“执行查询失败:所有选定的变量必须是聚合的,但 ?sdglabel 不是。”
谢谢!这很好用:
SELECT ?sdglabel (count(?ngo) as ?ngoCount)
WHERE {?ngo a ngo:NGORecipient;
ngo:hasSDGGoal ?goal.
?goal rdfs:label ?sdglabel.}
GROUP BY ?sdglabel
ORDER BY ?ngoCount
我不必担心具有相同标签的 IRI,因为不应该有任何 IRI。如果我理解,如果有的话它会失败,但只是为了确保我做了一个查询来测试具有不同 IRI 但相同标签的任何 SDG,并且正如我预期的那样,没有任何 SDG。