User:Reosarevok/Wikidata Example Queries: Difference between revisions

From MusicBrainz Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 9: Line 9:
SELECT ?entityLabel ?entity {
SELECT ?entityLabel ?entity {
?entity wdt:P106 wd:Q36834 .
?entity wdt:P106 wd:Q36834 .
MINUS { ?entity wdt:P434 [] } .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
</nowiki>


[https://query.wikidata.org/#%23Select%20composers%20who%20don%27t%20have%20a%20MusicBrainz%20ID%20stored%0ASELECT%20%3FentityLabel%20%3Fentity%20%7B%0A%09%3Fentity%20wdt%3AP106%20wd%3AQ36834%20.%0A%20%20%09MINUS%20%7B%20%3Fentity%20wdt%3AP434%20%5B%5D%20%7D%20.%0A%09SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20%7D%0A%7D Female composers who don't have a MusicBrainz ID stored]

For "musicians" instead of "composers", change Q36834 to Q639669.

<nowiki>
SELECT ?entityLabel ?entity {
?entity wdt:P106 wd:Q36834 .
?entity wdt:P21 wd:Q6581072 .
MINUS { ?entity wdt:P434 [] } .
MINUS { ?entity wdt:P434 [] } .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }

Revision as of 09:14, 10 March 2017

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

For "musicians" instead of "composers", change Q36834 to Q639669.

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 ?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)