User:Reosarevok/Wikidata Example Queries

From MusicBrainz Wiki
< User:Reosarevok
Revision as of 17:00, 14 November 2017 by Reosarevok (talk | contribs) (Add language to operas)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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" }
}
 


People who have composed at least one work that is in Wikidata and have no MBIDs, sorted by number of works

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" }
}