I would like to get Daft Punk\'s discography from dbpedia, and for each album I would like to show: 1) The title 2) The release year 3) The wikipedia page, so I wrote this
You could use the MIN
aggregate to extract the minimum value of the release year, when the result has been grouped using the GROUP BY feature of SPARQL 1.1.
For example, something like this:
PREFIX d: <http://dbpedia.org/ontology/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX : <http://dbpedia.org/resource/>
SELECT str(?name) MIN(YEAR(?relDate)) AS ?relYear ?wiki
WHERE {
?album a d:Album .
?album foaf:name ?name .
?album d:artist :Daft_Punk .
?album foaf:isPrimaryTopicOf ?wiki .
?album d:releaseDate ?relDate .
}
GROUP BY ?name ?wiki
ORDER BY ?relYear