query-33a5736fae1862d088ce5dc768f1390b

rq turtle/ttl

20:15, 16 August 2021 (UTC)) talk (Piecesofuk20:25, 16 August 2021 (UTC)) talk (PiecesofukOh I suspect you want the property...I'm stumped 06:39, 17 August 2021 (UTC)) talk (TagishsimonThanks; and sadly, yes, wrangling the property is where it all fails. -- : I slept on it and came up with this, is this right?Tagishsimon@

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?number ?property ?propertyLabel ?count ?maxcount  
WHERE {                              # right now, get labels and an aggregation which does nothing
   { SELECT ?item ?number ?property (COUNT(?predicate) as ?count) WHERE {  # get & count claims for the items
   { SELECT ?item ?number WHERE {     # get items having that many statements
   {
  SELECT ?number WHERE {                 # get numbers from 1k to 10k
  ?nn wdt:P31 wd:Q21199.
  ?nn wdt:P1181 ?number .
  FILTER (?number >= 1000 && ?number <= 10000)
} }  BIND(xsd:integer(?number) as ?b)
  ?item wikibase:statements ?b.
  FILTER NOT EXISTS {?item wdt:P31 wd:Q13442814 .}
 } }  ?item ?predicate [].
  ?property wikibase:claim ?predicate . 
} GROUP BY ?item ?number ?property ORDER BY DESC(?count) }   { SELECT  ?item (MAX(?count) AS ?maxcount) {
   { SELECT ?item ?number ?property (COUNT(?predicate) as ?count) WHERE {  # get & count claims for the items
  INCLUDE %j
  ?item ?predicate [].
  ?property wikibase:claim ?predicate . 
} GROUP BY ?item ?number ?property ORDER BY DESC(?count) }} GROUP BY ?item }  FILTER (?count = ?maxcount) 
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}  order by desc(?number)

Query found at