query-2412f6f724d7f8c37e7cbe00cc8b9f45
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 schema: <http://schema.org/>
SELECT ?item ?qid ?WP ?article ?sitelink ?thecode (GROUP_CONCAT (DISTINCT ?ich; separator= ",") AS ?ichid) (GROUP_CONCAT (DISTINCT ?inventory; separator= ",") AS ?inventories) (GROUP_CONCAT (DISTINCT ?type; separator= ",") AS ?types) (GROUP_CONCAT(DISTINCT ?region; SEPARATOR = ",") AS ?regions) (SAMPLE(?image) AS ?image) WHERE {
{
{ ?item wdt:P6104 wd:Q112898263. }
UNION
{ ?item wdt:P3259 ?ichstatus. }
}
?item wdt:P17|wdt:P495|wdt:P183|wdt:P2596|wdt:P3259/wdt:P17|wdt:P2541|wdt:P2341 wd:Q33 .
MINUS { ?item (wdt:P31/wdt:P279*) wd:Q116056897. }
MINUS { ?item wdt:P31 wd:Q13406463 . }
BIND(SUBSTR(STR(?item), 32) AS ?qid)
OPTIONAL { ?item wdt:P17|wdt:P495|wdt:P183|wdt:P2596|wdt:P3259/wdt:P17|wdt:P2541|wdt:P2341 ?reg. }
OPTIONAL { ?item wdt:P10221 ?ich. }
BIND(SUBSTR(STR(?reg), 32 ) AS ?region)
OPTIONAL { ?item wdt:P18 ?img.
BIND(CONCAT('File:',wikibase:decodeUri(SUBSTR(STR(?img), 52))) AS ?image)
}
OPTIONAL { ?item wdt:P31 ?P31.
BIND(SUBSTR(STR(?P31), 32) AS ?type)
}
OPTIONAL { ?item wdt:P3259 ?inv.
BIND(SUBSTR(STR(?inv), 32) AS ?inventory)
}
OPTIONAL { ?article schema:about ?item;
schema:inLanguage ?thecode;
schema:name ?sitelink;
schema:isPartOf ?WP.
?WP wikibase:wikiGroup "wikipedia" .
OPTIONAL {
?sitelink wikibase:badge ?badge.
}
}
}
GROUP BY ?item ?qid ?article ?sitelink ?thecode ?WP
ORDER BY DESC (?image)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?P31")
v16("?WP"):::projected
v13("?article"):::projected
v17("?badge")
v6("?ich"):::projected
v18("?ichid")
v3("?ichstatus")
v22("?image"):::projected
v8("?img")
v11("?inv")
v19("?inventories")
v12("?inventory"):::projected
v2("?item"):::projected
v4("?qid"):::projected
v5("?reg")
v7("?region"):::projected
v21("?regions")
v15("?sitelink"):::projected
v14("?thecode"):::projected
v10("?type"):::projected
v20("?types")
a1((" "))
a2((" "))
a3((" "))
c13(["wd:Q116056897"]):::iri
c2(["wd:Q112898263"]):::iri
c5(["wd:Q33"]):::iri
c14(["wd:Q13406463"]):::iri
c22(["wikipedia"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P3259"--> v3
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P6104"--> c2
end
union0r <== or ==> union0l
end
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
subgraph union3[" Union "]
subgraph union3l[" "]
style union3l fill:#abf,stroke-dasharray: 3 3;
subgraph union4[" Union "]
subgraph union4l[" "]
style union4l fill:#abf,stroke-dasharray: 3 3;
subgraph union5[" Union "]
subgraph union5l[" "]
style union5l fill:#abf,stroke-dasharray: 3 3;
subgraph union6[" Union "]
subgraph union6l[" "]
style union6l fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P2341"--> c5
end
subgraph union6r[" "]
style union6r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P2541"--> c5
end
union6r <== or ==> union6l
end
end
subgraph union5r[" "]
style union5r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P3259"--> a1
a1 --"wdt:P17"--> c5
end
union5r <== or ==> union5l
end
end
subgraph union4r[" "]
style union4r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P2596"--> c5
end
union4r <== or ==> union4l
end
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P183"--> c5
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P495"--> c5
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P17"--> c5
end
union1r <== or ==> union1l
end
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
v2 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c13
end
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
v2 --"wdt:P31"--> c14
end
bind2[/"substring(str(?item),'32^^xsd:integer')"/]
v2 --o bind2
bind2 --as--o v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
subgraph union7[" Union "]
subgraph union7l[" "]
style union7l fill:#abf,stroke-dasharray: 3 3;
subgraph union8[" Union "]
subgraph union8l[" "]
style union8l fill:#abf,stroke-dasharray: 3 3;
subgraph union9[" Union "]
subgraph union9l[" "]
style union9l fill:#abf,stroke-dasharray: 3 3;
subgraph union10[" Union "]
subgraph union10l[" "]
style union10l fill:#abf,stroke-dasharray: 3 3;
subgraph union11[" Union "]
subgraph union11l[" "]
style union11l fill:#abf,stroke-dasharray: 3 3;
subgraph union12[" Union "]
subgraph union12l[" "]
style union12l fill:#abf,stroke-dasharray: 3 3;
v2 -."wdt:P2341".-> v5
end
subgraph union12r[" "]
style union12r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P2541"--> v5
end
union12r <== or ==> union12l
end
end
subgraph union11r[" "]
style union11r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P3259"--> a3
a3 --"wdt:P17"--> v5
end
union11r <== or ==> union11l
end
end
subgraph union10r[" "]
style union10r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P2596"--> v5
end
union10r <== or ==> union10l
end
end
subgraph union9r[" "]
style union9r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P183"--> v5
end
union9r <== or ==> union9l
end
end
subgraph union8r[" "]
style union8r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P495"--> v5
end
union8r <== or ==> union8l
end
end
subgraph union7r[" "]
style union7r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P17"--> v5
end
union7r <== or ==> union7l
end
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P10221".-> v6
end
bind3[/"substring(str(?reg),'32^^xsd:integer')"/]
v5 --o bind3
bind3 --as--o v7
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P18".-> v8
bind4[/"concat('File:',http://wikiba.se/ontology#decodeUri(substring(str(?img),'52^^xsd:integer')))"/]
v8 --o bind4
bind4 --as--o v22
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P31".-> v9
bind5[/"substring(str(?P31),'32^^xsd:integer')"/]
v9 --o bind5
bind5 --as--o v10
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P3259".-> v11
bind6[/"substring(str(?inv),'32^^xsd:integer')"/]
v11 --o bind6
bind6 --as--o v12
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v13 -."schema:about".-> v2
v13 --"schema:inLanguage"--> v14
v13 --"schema:name"--> v15
v13 --"schema:isPartOf"--> v16
v16 --"wikibase:wikiGroup"--> c22
subgraph optional6["(optional)"]
style optional6 fill:#bbf,stroke-dasharray: 5 5;
v15 -."wikibase:badge".-> v17
end
end
bind12[/"?ich"/]
v6 --o bind12
bind12 --as--o v18
bind13[/"?inventory"/]
v12 --o bind13
bind13 --as--o v19
bind14[/"?type"/]
v10 --o bind14
bind14 --as--o v20
bind15[/"?region"/]
v7 --o bind15
bind15 --as--o v21
bind16[/"sample(?image)"/]
v22 --o bind16
bind16 --as--o v22