query-b1acfe5d9f8a2b9e1874fe2b79c076c0
SPARQL query
Use at
- https://query.wikidata.org/sparql
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/>
SELECT ?wikidata ?start_date ?end_date ?wikidata_group ?wikidata_area WHERE {
?wikidata p:P39 ?mem .
?mem ps:P39 wd:Q33512801.
OPTIONAL { ?mem pq:P580 ?start }
OPTIONAL { ?mem pq:P582 ?end }
OPTIONAL { ?mem pq:P4100 ?wikidata_group }
OPTIONAL { ?mem pq:P768 ?wikidata_area }
BIND(SUBSTR(str(?start),1,10) AS ?start_iso)
BIND(SUBSTR(str(?end),1,10) AS ?end_date)
BIND(IF(?start_iso = '2013-06-01', '', ?start_iso) AS ?start_date)
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?end")
v8("?end_date"):::projected
v2("?mem")
v3("?start")
v9("?start_date"):::projected
v7("?start_iso")
v1("?wikidata"):::projected
v6("?wikidata_area"):::projected
v5("?wikidata_group"):::projected
c3(["wd:Q33512801"]):::iri
v1 --"p:P39"--> v2
v2 --"p:statement/P39"--> c3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P580".-> v3
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P582".-> v4
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P4100".-> v5
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P768".-> v6
end
bind0[/"substring(str(?start),'1^^xsd:integer','10^^xsd:integer')"/]
v3 --o bind0
bind0 --as--o v7
bind1[/"substring(str(?end),'1^^xsd:integer','10^^xsd:integer')"/]
v4 --o bind1
bind1 --as--o v8
bind2[/"if(?start_iso = '2013-06-01','',?start_iso)"/]
v7 --o bind2
bind2 --as--o v9