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 (COUNT(?composition) AS ?count) ?composerLabel ?composer WHERE { ?composition wdt:P86 ?composer . ?composer wdt:P106 wd:Q639669 . MINUS { ?composer wdt:P434 [] } . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?composerLabel ?composer ORDER BY DESC(?count)
Operas that don't have a MusicBrainz ID stored
SELECT ?entityLabel ?entity ?languageLabel { ?entity wdt:P31 wd:Q1344 . MINUS { ?entity wdt:P435 [] } . OPTIONAL { ?entity wdt:P407 ?language } . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } }