User:Reosarevok/Wikidata Example Queries
From MusicBrainz Wiki
Jump to navigationJump to search
These are example queries for the Wikidata SPARQL endpoint
All composers who don't have a MusicBrainz ID stored
For "musicians" instead of "composers", change Q36834 to Q639669.
SELECT ?entityLabel ?entity { ?entity wdt:P106 wd:Q36834 . MINUS { ?entity wdt:P434 [] } . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } }
Female composers who don't have a MusicBrainz ID stored
SELECT ?entityLabel ?entity { ?entity wdt:P106 wd:Q36834 . ?entity wdt:P21 wd:Q6581072 . MINUS { ?entity wdt:P434 [] } . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } }
Composers born somewhere in Germany who don't have a MusicBrainz ID stored
SELECT ?entityLabel ?entity { ?entity wdt:P106 wd:Q36834 . ?entity wdt:P19 ?place . ?place wdt:P17 wd:Q183 . MINUS { ?entity wdt:P434 [] } . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } }
SELECT ?composer ?composerLabel ?count WHERE { { SELECT ?composer (COUNT(?composition) AS ?count) WHERE { ?composition wdt:P86 ?composer; MINUS { ?composer wdt:P434 [] } . } GROUP BY ?composer } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } ORDER BY DESC(?count)