User:Reosarevok/Wikidata Example Queries: Difference between revisions
From MusicBrainz Wiki
Jump to navigationJump to search
Reosarevok (talk | contribs) (Created page with "These are example queries for the [https://query.wikidata.org/ Wikidata SPARQL endpoint] [https://query.wikidata.org/#%23Select%20composers%20who%20don%27t%20have%20a%20Musi...") |
Reosarevok (talk | contribs) No edit summary |
||
Line 25: | Line 25: | ||
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } |
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } |
||
} |
} |
||
</nowiki> |
|||
[https://query.wikidata.org/#%23Composers%20who%20don%27t%20have%20a%20MusicBrainz%20ID%20stored%2C%20sorted%20by%20number%20of%20compositions%0ASELECT%20%28COUNT%28%3Fcomposition%29%20AS%20%3Fcount%29%20%3FcomposerLabel%20%3Fcomposer%20%0AWHERE%20%7B%20%0A%20%20%20%20%3Fcomposer%20wdt%3AP106%20wd%3AQ639669%20.%0A%20%20%09MINUS%20%7B%20%3Fcomposer%20wdt%3AP434%20%5B%5D%20%7D%20.%0A%20%20%20%20%7B%0A%20%20%20%20SELECT%20%3Fcomposer%20%28COUNT%28%3Fcomposition%29%20AS%20%3Fcount%29%0A%20%20%20%20WHERE%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%3Fcomposition%20wdt%3AP86%20%3Fcomposer%20.%0A%20%20%20%20%7D%0A%20%20%20%20GROUP%20BY%20%3Fcomposer%20%7D%0A%20%20%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20%7D%0A%7D%0AORDER%20BY%20DESC%28%3Fcount%29 People who have composed at least one work that is in Wikidata and have no MBIDs, sorted by number of works] |
|||
<nowiki> |
|||
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) |
|||
</nowiki> |
</nowiki> |
Revision as of 13:54, 9 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" } }
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)