query-fdcc7e1f330dc91d3933895bab871e88
TODO
Use at
- https://query.wikidata.org/sparql
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 ?INSEE ?itemLabel (CONCAT("[[Wikidata:WikiProject France/Églises/",?INSEE,"\u007C",?itemLabel,"]]") AS ?LIEN) ?depCount (IF(?_withCoord > ?depCount, 0, ?depCount - ?_withCoord) AS ?withoutCoord) (IF(?_withImg > ?depCount, 0, ?depCount - ?_withImg) AS ?withoutImg) (ROUND((IF(?_withCoord > ?depCount, ?depCount, ?_withCoord) / ?depCount) * 100 * 100) / 100 AS ?withCoord) (ROUND((IF(?_withImg > ?depCount, ?depCount, ?_withImg) / ?depCount) * 100 * 100) / 100 AS ?withImg)
WHERE {
{
SELECT ?item (COUNT(DISTINCT ?item2) AS ?depCount) (COUNT(DISTINCT ?coord) AS ?_withCoord) (COUNT(DISTINCT ?img) AS ?_withImg) WHERE {
?commune wdt:P31/wdt:P279* wd:Q484170 .
?item2 wdt:P31/wdt:P279* wd:Q16970.
?item2 wdt:P131 ?commune.
?commune wdt:P131 ?item .
?item wdt:P2586 ?INSEE .
OPTIONAL { ?item2 wdt:P625 ?coord } .
OPTIONAL { ?item2 wdt:P18 ?img } .
} GROUP BY ?item
} .
?item wdt:P2586 ?INSEE .
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" } .
}
ORDER BY ?INSEE
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?INSEE"):::projected
v10("?LIEN")
v8("?_withCoord"):::projected
v9("?_withImg"):::projected
v2("?commune")
v5("?coord")
v7("?depCount"):::projected
v6("?img")
v4("?item"):::projected
v3("?item2")
v13("?withCoord")
v14("?withImg")
v11("?withoutCoord")
v12("?withoutImg")
a1((" "))
a2((" "))
c10(["bd:serviceParam"]):::iri
c4(["wd:Q16970"]):::iri
c12(["fr"]):::literal
c3(["wd:Q484170"]):::iri
v2 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c3
v3 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c4
v3 --"wdt:P131"--> v2
v2 --"wdt:P131"--> v4
v4 --"wdt:P2586"--> v1
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P625".-> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P18".-> v6
end
bind3[/"count(?item2)"/]
v3 --o bind3
bind3 --as--o v7
bind4[/"count(?coord)"/]
v5 --o bind4
bind4 --as--o v8
bind5[/"count(?img)"/]
v6 --o bind5
bind5 --as--o v9
v4 --"wdt:P2586"--> v1
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end
bind6[/"concat('#91;#91;Wikidata:WikiProject France/Églises/',?INSEE,'|',?itemLabel,'#93;#93;')"/]
v1 --o bind6
null --o bind6
bind6 --as--o v10
bind7[/"if(?_withCoord > ?depCount,'0^^xsd:integer',?depCount - ?_withCoord)"/]
v8 --o bind7
v7 --o bind7
bind7 --as--o v11
bind8[/"if(?_withImg > ?depCount,'0^^xsd:integer',?depCount - ?_withImg)"/]
v9 --o bind8
v7 --o bind8
bind8 --as--o v12
bind9[/"numeric-round(if(?_withCoord > ?depCount,?depCount,?_withCoord) / ?depCount * '100^^xsd:integer' * '100^^xsd:integer') / '100^^xsd:integer'"/]
v8 --o bind9
v7 --o bind9
bind9 --as--o v13
bind10[/"numeric-round(if(?_withImg > ?depCount,?depCount,?_withImg) / ?depCount * '100^^xsd:integer' * '100^^xsd:integer') / '100^^xsd:integer'"/]
v9 --o bind10
v7 --o bind10
bind10 --as--o v14