query-61a82a6cedf6db42d21b2ff968ce45a1

rq turtle/ttl

title:Most common properties (excluding external ids) for a type of item on a given Wikipedia SELECT ?id (COUNT(DISTINCT ?item)*100/?total AS ?percent) # ?idlabel WITH { SELECT ?item WHERE { ?item wdt:P31/wdt:P279? wd:Q5398426 . ?arwp schema:about ?item ; schema:isPartOf https://ary.wikipedia.org/ } } AS %list WITH { SELECT (COUNT(?item) AS ?total) WHERE { ?item wdt:P31/wdt:P279? wd:Q5398426 . ?arwp schema:about ?item ; schema:isPartOf https://ary.wikipedia.org/ } } AS %total WHERE { include %list . include %total . ?item ?p [] . ?id wikibase:claim ?p FILTER(?id != wd:P31). MINUS { ?id wikibase:propertyType wikibase:ExternalId } # ?id rdfs:label ?idlabel FILTER (lang(?idlabel) = "en") } GROUP BY ?id ?total # ?idlabel ORDER BY DESC(?percent) LIMIT 20

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#title:Most common properties (excluding external ids) for a type of item on a given Wikipedia
SELECT ?id (COUNT(DISTINCT ?item)*100/?total AS ?percent) # ?idlabel
WHERE {
   {
 SELECT ?item WHERE {
  ?item wdt:P31/wdt:P279? wd:Q5398426 .
   ?arwp schema:about ?item ; schema:isPartOf <https://ary.wikipedia.org/>
 } }.
   { SELECT (COUNT(?item) AS ?total) WHERE {
  ?item wdt:P31/wdt:P279? wd:Q5398426 .
   ?arwp schema:about ?item ; schema:isPartOf <https://ary.wikipedia.org/>
 } }.
  ?item ?p [] .
  ?id wikibase:claim ?p FILTER(?id != wd:P31).
  MINUS { ?id wikibase:propertyType wikibase:ExternalId }
 #  ?id rdfs:label ?idlabel FILTER (lang(?idlabel) = "en")
} GROUP BY ?id ?total # ?idlabel
ORDER BY DESC(?percent)
LIMIT 20

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?arwp") v2("?id"):::projected v3("?item") v6("?p") v7("?percent") v5("?total"):::projected a3((" ")) a1((" ")) a2((" ")) c3(["wd:Q5398426"]):::iri c7([https://ary.wikipedia.org/]):::iri c10(["wikibase:ExternalId"]):::iri f0[["?id != 'wd:P31'"]] f0 --> v2 v3 --"wdt:P31"--> a1 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P279"--> c3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; end union0r <== or ==> union0l end v4 --"schema:about"--> v3 v4 --"schema:isPartOf"--> c7 v3 --"wdt:P31"--> a2 subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; a2 --"wdt:P279"--> c3 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; end union1r <== or ==> union1l end v4 --"schema:about"--> v3 v4 --"schema:isPartOf"--> c7 bind2[/"count(?item)"/] v3 --o bind2 bind2 --as--o v5 v3 -->v6--> a3 v2 --"wikibase:claim"--> v6 subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v2 --"wikibase:propertyType"--> c10 end bind5[/" * '100^^xsd:integer' / ?total"/] null --o bind5 v5 --o bind5 bind5 --as--o v7