query-a8dbdd2645bc81d2d72e44df7e22edee
Number of P143 sources (by property)
Use at
- https://query.wikidata.org/sparql
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?property ?propertyLabel ?cnt_s ?cnt_refs ?ratio WHERE {
{
SELECT ?property (COUNT(DISTINCT ?s) AS ?cnt_s) (COUNT(DISTINCT ?dummy) as ?cnt_refs) WHERE {
{
SELECT DISTINCT ?property ?s WHERE {
[] p:P106/ps:P106/wdt:P279* wd:Q26270618; ?p ?s .
?property wikibase:claim ?p; wikibase:propertyType ?type .
FILTER(?type != wikibase:ExternalId) .
}
}.
OPTIONAL {
?s prov:wasDerivedFrom ?refHandle .
?refHandle pr:P143 ?val . # P143, P887, P4656, P3452, P5852
}
BIND(CONCAT(STR(?s), STR(?refHandle)) AS ?dummy) .
} GROUP BY ?property HAVING(?cnt_refs > 0)
}.
BIND(CONCAT(STR(ROUND((?cnt_refs / ?cnt_s)*1000)/10), '%') AS ?ratio) .
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} ORDER BY DESC(?cnt_refs) DESC(xsd:integer(STRBEFORE(?ratio, '%')))
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v11("?cnt_refs"):::projected
v10("?cnt_s"):::projected
v9("?dummy")
v4("?p")
v6("?property"):::projected
v11("?ratio"):::projected
v7("?refHandle")
v5("?s")
v3("?type")
v8("?val")
a1((" "))
a2((" "))
a3((" "))
c15(["en"]):::literal
c13(["bd:serviceParam"]):::iri
c7(["wd:Q26270618"]):::iri
f0[["?cnt_refs > '0^^xsd:integer'"]]
f0 --> v11
f1[["?type != 'wikibase:ExternalId'"]]
f1 --> v3
a1 --"p:P106"--> a2
a2 --"p:statement/P106"--> a3
a3 --"p:direct/P279"--> c7
a1 -->v4--> v5
v6 --"wikibase:claim"--> v4
v6 --"wikibase:propertyType"--> v3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."prov:wasDerivedFrom".-> v7
v7 --"p:reference/P143"--> v8
end
bind2[/"concat(str(?s),str(?refHandle))"/]
v5 --o bind2
v7 --o bind2
bind2 --as--o v9
bind5[/"count(?s)"/]
v5 --o bind5
bind5 --as--o v10
bind6[/"count(?dummy)"/]
v9 --o bind6
bind6 --as--o v11
bind7[/"concat(str(numeric-round(?cnt_refs / ?cnt_s * '1000^^xsd:integer') / '10^^xsd:integer'),'%')"/]
v11 --o bind7
v10 --o bind7
bind7 --as--o v11
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c13 --"wikibase:language"--> c15
end