User:TweetsFactsAndQueries/Queries/items with most MusicBrainz IDs

From Wikidata
Jump to navigation Jump to search

Originally posted on Twitter and on Mastodon.

# items with most MusicBrainz IDs
SELECT ?item ?itemLabel ?itemDescription ?propertyLabel ?count ?hasSingleValueConstraint WITH {
  SELECT ?item ?property (COUNT(?musicBrainzIdStatement) AS ?count) WHERE {
    ?property a wikibase:Property;
              wdt:P2378 wd:Q14005;
              wikibase:claim ?p.
    ?item ?p ?musicBrainzIdStatement.
  }
  GROUP BY ?item ?property
  ORDER BY DESC(?count)
  LIMIT 100
} AS %results WHERE {
  INCLUDE %results.
  BIND(EXISTS { ?property wdt:P2302 wd:Q19474404. } AS ?hasSingleValueConstraint)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?count)
Try it!