query-cbd9b467b4d2cbda46d4853413ae9ead

rq turtle/ttl

Propertiescountry (P17)PM20 folder ID (P4293)mapping relation type (P4390)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
select (count(?item) as ?count) ?country ?countryLabel
where {
  # company items (directly linked)
  ?statement ps:P4293 ?pm20Id .
  filter(strstarts(?pm20Id, 'co/'))
  ?item p:P4293 ?statement .
  filter (not exists {
      ?statement pq:P4390 [] .
    })
  #
  ?item wdt:P17 ?country .
  service wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr". }
}
group by ?country ?countryLabel
order by desc(?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?count") v5("?country"):::projected v4("?item"):::projected v3("?pm20Id") v2("?statement") a1((" ")) c9(["#91;AUTO_LANGUAGE#93;,en,de,fr"]):::literal c7(["bd:serviceParam"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P4390"--> e0a1 e0v1("?statement"):::projected e0a1((" ")):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> a1 v2 --"p:qualifier/P4390"--> a1 f1[["starts-with(?pm20Id,'co/')"]] f1 --> v3 v2 --"p:statement/P4293"--> v3 v4 --"p:P4293"--> v2 v4 --"p:direct/P17"--> v5 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end bind3[/"count(?item)"/] v4 --o bind3 bind3 --as--o v6