query-f20fc1207797ffbd22bb3addff3e0d52
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 pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel (SUM(?colors) AS ?colors_without_P518) (COUNT(?colorstatement) AS ?all_colors) WHERE
{
?item wdt:P31 wd:Q39715 .
?item wdt:P17 wd:Q34 .
?item p:P462 ?colorstatement .
OPTIONAL {?colorstatement pq:P518 ?del . }
BIND(IF(BOUND(?del),0,1) AS ?colors)
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
}
GROUP BY ?item ?itemLabel
ORDER BY DESC(?colors_without_P518) ?itemLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?all_colors")
v6("?colors"):::projected
v7("?colors_without_P518")
v4("?colorstatement"):::projected
v5("?del")
v3("?item"):::projected
v2("?itemLabel"):::projected
c8(["bd:serviceParam"]):::iri
c10(["sv,en"]):::literal
c2(["wd:Q39715"]):::iri
c4(["wd:Q34"]):::iri
v3 --"p:direct/P31"--> c2
v3 --"p:direct/P17"--> c4
v3 --"p:P462"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:qualifier/P518".-> v5
end
bind0[/"if(bound(?del),'0^^xsd:integer','1^^xsd:integer')"/]
v5 --o bind0
bind0 --as--o v6
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
end
bind3[/"sum(?colors)"/]
v6 --o bind3
bind3 --as--o v7
bind4[/"count(?colorstatement)"/]
v4 --o bind4
bind4 --as--o v7