SPARQL WikiData - Beethoven's premiers

Context: I would like to query premier performances of Beethoven’s compositions using WikiData. I have the individual pieces, but can’t seem to put them together correctly.

Pieces: The id for Beethoven is Q255. The id for all his works is Q24953042. There is a property called date of first performance (P1191), as seen here for Symphony #9 Symphony No. 9 - Wikidata.

First, I tried querying just the compositions of Beethoven with:
SELECT ?composition
WHERE {?composition wdt:P31 wd:Q24953042 .
SERVICE wikibase:label {
bd:serviceParam wikibase:language “en” .
}
}
However, that returned no results.

Then I noticed that compositions by Beethoven are their own category, so I tried
SELECT ?composition
WHERE {?composition wdt:P31 wd:Q7132900 .
SERVICE wikibase:label {
bd:serviceParam wikibase:language “en” .
}
}
which also didn’t return any results.

Can someone point out what I am doing wrong? Thanks!

2 Likes

Here are Symphonies (Q9734) composed by (P86) Beethoven
SELECT ?composition
WHERE {
?composition wdt:P31 wd:Q9734;
wdt:P86 wd:Q255.
SERVICE wikibase:label {
bd:serviceParam wikibase:language “en” .
}
}
see also https://w.wiki/zz8

And if you removed the symphony filter you will get all of his works:
SELECT ?composition
WHERE {
?composition wdt:P86 wd:Q255.
SERVICE wikibase:label {
bd:serviceParam wikibase:language “en” .
}
}
https://w.wiki/zzA

1 Like

And a good resource to check when doing Wikidata and SPARQL The Wikidata data model and your SPARQL queries

Thank you, François! with the P86, I was able to put together the final query:

SELECT ?composition_name ?premier 
WHERE {
  ?composition wdt:P86 wd:Q255 .
  ?composition rdfs:label ?composition_name 
  FILTER (LANG(?composition_name)="en") .
  ?composition wdt:P1191 ?premier .

}

2 Likes