query-de3337acf94caa3268d1987b310d6720
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
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 ?lgu ?lguLabel ?incomeClassText ?sameRefUrl ?incomeClassRefUrl ?incomeClassRefRetrieved WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
{ ?lgu wdt:P31/wdt:P279* wd:Q104157 } UNION { ?lgu wdt:P31 wd:Q24764 }
?lgu p:P988 ?psgcStatement .
?psgcStatement ps:P988 ?psgc .
?psgcStatement prov:wasDerivedFrom ?psgcRef .
?psgcRef pr:P854 ?psgcRefUrl .
OPTIONAL { ?psgcRef pr:P813 ?psgcRefRetrieved }
?lgu p:P1879 ?incomeClassStatement .
{
?incomeClassStatement a wdno:P1879 .
BIND("—" as ?incomeClassText) .
}
UNION
{
?incomeClassStatement ps:P1879 ?incomeClass .
?incomeClass rdfs:label ?incomeClassText .
FILTER (lang(?incomeClassText) = 'en')
}
?incomeClassStatement prov:wasDerivedFrom ?incomeClassRef .
?incomeClassRef pr:P854 ?incomeClassRefUrl .
OPTIONAL { ?incomeClassRef pr:P813 ?incomeClassRefRetrieved }
BIND(IF(?psgcRefUrl = ?incomeClassRefUrl, "Same", "—") AS ?sameRefUrl) .
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?incomeClass")
v10("?incomeClassRef")
v12("?incomeClassRefRetrieved"):::projected
v11("?incomeClassRefUrl"):::projected
v7("?incomeClassStatement")
v8("?incomeClassText"):::projected
v1("?lgu"):::projected
v3("?psgc")
v4("?psgcRef")
v6("?psgcRefRetrieved")
v5("?psgcRefUrl")
v2("?psgcStatement")
v13("?sameRefUrl"):::projected
a1((" "))
c16(["p:novalue/P1879"]):::iri
c7(["wd:Q104157"]):::iri
c8(["wd:Q24764"]):::iri
c2(["bd:serviceParam"]):::iri
c4(["#91;AUTO_LANGUAGE#93;,en"]):::literal
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P31"--> c8
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> c7
end
union0r <== or ==> union0l
end
v1 --"p:P988"--> v2
v2 --"p:statement/P988"--> v3
v2 --"prov:wasDerivedFrom"--> v4
v4 --"p:reference/P854"--> v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:reference/P813".-> v6
end
v1 --"p:P1879"--> v7
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
f0[["?incomeClassText = 'en'"]]
f0 --> v8
v7 --"p:statement/P1879"--> v9
v9 --"rdfs:label"--> v8
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v7 --"a"--> c16
bind1[/"'—'"/]
bind1 --as--o v8
end
union1r <== or ==> union1l
end
v7 --"prov:wasDerivedFrom"--> v10
v10 --"p:reference/P854"--> v11
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v10 -."p:reference/P813".-> v12
end
bind2[/"if(?psgcRefUrl = ?incomeClassRefUrl,'Same','—')"/]
v5 --o bind2
v11 --o bind2
bind2 --as--o v13