The following query is working:
SELECT ?goal (count(?ngo) as ?ngoCount)
WHERE {?ngo a ngo:NGORecipient;
ngo:hasSDGGoal ?goal.
?goal rdfs:label ?sdglabel.}
GROUP BY ?goal
ORDER BY ?ngoCount
However, when I go to get the label rather than the IRI as follows
SELECT ?sdglabel (count(?ngo) as ?ngoCount)
WHERE {?ngo a ngo:NGORecipient;
ngo:hasSDGGoal ?goal.
?goal rdfs:label ?sdglabel.}
GROUP BY ?goal
ORDER BY ?ngoCount
I get an error: "Executing query failed: All selected variables must be aggregates but ?sdglabel is not."
Thanks! This works fine:
I don't have to worry about IRIs with the same label because there shouldn't be any. If I'm understanding it would fail if there were but just to be sure I did a query to test for any SDGs with different IRIs but the same label and as I expected there aren't any.