问题
I want to get the scorers
(marcatori
) from this page: http://it.dbpedia.org/resource/Modena_Football_Club_1962-1963
using this SPARQL endpoint: http://uriburner.com/sparql/
If I use this query:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT
?team
?club
(group_concat(distinct ?scorer;separator=";;;") as ?scorers)
WHERE {
SERVICE <http://it.dbpedia.org/sparql/> {
?value rdfs:label "Campionato italiano di calcio Serie A"@it .
?year <http://purl.org/dc/terms/subject> ?value .
?team <http://dbpedia.org/ontology/league> ?year .
?team <http://it.dbpedia.org/property/club> ?club .
OPTIONAL { ?team <http://it.dbpedia.org/property/marcatori> ?scorer
}
}
}
GROUP BY ?team ?club
ORDER BY ?club
LIMIT 1
I get no results, where as if I use this one:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT
?team
?club
WHERE {
SERVICE <http://it.dbpedia.org/sparql/> {
?value rdfs:label "Campionato italiano di calcio Serie A"@it .
?year <http://purl.org/dc/terms/subject> ?value .
?team <http://dbpedia.org/ontology/league> ?year .
?team <http://it.dbpedia.org/property/club> ?club
}
}
GROUP BY ?team ?club
ORDER BY ?club
LIMIT 1
I correctly get:
{ "head": { "link": [], "vars": ["team", "club"] },
"results": { "distinct": false, "ordered": true, "bindings": [
{ "team": { "type": "uri", "value":
"http://it.dbpedia.org/resource/Modena_Football_Club_1962-1963" } ,
"club": { "type": "uri", "value":
"http://it.dbpedia.org/resource/Modena_Football_Club" }} ] } }
Does anyone know why the first query returns empty?
回答1:
You can replace
(group_concat(distinct ?scorer;separator=";;;") as ?scorers)
with
sql:group_concat(?scorer, ";;;") as ?scorers
This should work fine on http://it.dbpedia.org/sparql, not sure why you need URI burner.
来源:https://stackoverflow.com/questions/53499065/difference-between-one-sparql-working-query-and-another-one-not-working