query-766143e5da6ad02636f3c848919c3b62

rq turtle/ttl

Most common properties (excluding external ids) for a type of item on a given Wikipedia SELECT ?id ?idlabel (round(?count*1000/?total)/10 AS ?percent) 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 { include %list } } AS %total WITH { SELECT ?id (COUNT(DISTINCT ?item) AS ?count) WHERE { include %list ?item ?p [] . ?id wikibase:claim ?p . FILTER(?p != p:P31) MINUS { ?id wikibase:propertyType wikibase:ExternalId } } GROUP BY ?id } AS %props WHERE { include %props include %total ?id rdfs:label ?idlabel . FILTER (lang(?idlabel) = "en") } ORDER BY DESC(?percent) LIMIT 50

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#>
PREFIX p: <http://www.wikidata.org/prop/>
# Most common properties (excluding external ids) for a type of item on a given Wikipedia
SELECT ?id ?idlabel (round(?count*1000/?total)/10 AS ?percent)
WHERE {
   {
  SELECT ?id (COUNT(DISTINCT ?item) AS ?count) WHERE {
     {
  SELECT ?item 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(?p != p:P31)
    MINUS { ?id wikibase:propertyType wikibase:ExternalId }
  }
  GROUP BY ?id
}   {
  SELECT (COUNT(?item) AS ?total) WHERE {
     {
  SELECT ?item WHERE {
    ?item wdt:P31/wdt:P279? wd:Q5398426 .
    ?arwp schema:about ?item ; schema:isPartOf <https://ary.wikipedia.org/>
  }
}  }
}  ?id rdfs:label ?idlabel . FILTER (lang(?idlabel) = "en")
}
ORDER BY DESC(?percent)
LIMIT 50

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?arwp") v7("?count"):::projected v6("?id"):::projected v2("?idlabel"):::projected v4("?item") v3("?p") v9("?percent") v8("?total"):::projected a2((" ")) a1((" ")) a3((" ")) c4(["wd:Q5398426"]):::iri c8([https://ary.wikipedia.org/]):::iri c11(["wikibase:ExternalId"]):::iri f0[["?idlabel = 'en'"]] f0 --> v2 f1[["?p != 'p:P31'"]] f1 --> v3 v4 --"p:direct/P31"--> a1 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; a1 --"p:direct/P279"--> c4 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; end union0r <== or ==> union0l end v5 --"schema:about"--> v4 v5 --"schema:isPartOf"--> c8 v4 -->v3--> a2 v6 --"wikibase:claim"--> v3 subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v6 --"wikibase:propertyType"--> c11 end bind4[/"count(?item)"/] v4 --o bind4 bind4 --as--o v7 v4 --"p:direct/P31"--> a3 subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; a3 --"p:direct/P279"--> c4 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; end union1r <== or ==> union1l end v5 --"schema:about"--> v4 v5 --"schema:isPartOf"--> c8 bind6[/"count(?item)"/] v4 --o bind6 bind6 --as--o v8 v6 --"rdfs:label"--> v2 bind7[/"numeric-round(?count * '1000^^xsd:integer' / ?total) / '10^^xsd:integer'"/] v7 --o bind7 v8 --o bind7 bind7 --as--o v9