query-c84ea5b991f2260a4cca53909536fe79
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
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 ?tLabel (COALESCE(?applies,'error:applies is not bound') AS ?test_of_applies) (if(?applies=wd:Q854248,1,0) as ?up_only) (if(BOUND(?applies)&&?applies=wd:Q844947,1,0) as ?down_only)
WHERE
{
values ?item {wd:Q384250} .
optional {?item p:P1029 ?tom.
optional {?tom pq:P518 ?applies.
?tom ps:P1029 ?t } }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?applies"):::projected
v7("?down_only")
v1("?item"):::projected
v4("?t")
v5("?test_of_applies")
v2("?tom")
v6("?up_only")
c5(["bd:serviceParam"]):::iri
c7(["#91;AUTO_LANGUAGE#93;,en"]):::literal
bind0[/VALUES ?item/]
bind0-->v1
bind00(["wd:Q384250"])
bind00 --> bind0
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:P1029".-> v2
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P518".-> v3
v2 --"p:statement/P1029"--> v4
end
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end
bind1[/"?applies'error:applies is not bound'"/]
v3 --o bind1
bind1 --as--o v5
bind2[/"if(?applies = 'wd:Q854248','1^^xsd:integer','0^^xsd:integer')"/]
v3 --o bind2
bind2 --as--o v6
bind3[/"if(bound(?applies)?applies = 'wd:Q844947','1^^xsd:integer','0^^xsd:integer')"/]
v3 --o bind3
bind3 --as--o v7