query-72ea257ccbf60ea4440aee28a5473074
11:49, 28 February 2017 (UTC)) talk (MdmahirPlease help. Thanks -- I have fixed it myself.
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
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 ?desc ?state ?stateLabel ?eyear ?member ?memberLabel WHERE {
BIND(wd:Q1445 as ?state) # Tamil Nadu
BIND (wd:Q3532431 as ?name)
BIND (wd:Q3429959 as ?constituency)
?item wdt:P31/wdt:P279* ?constituency. # constituency
?item p:P131 ?statement . # get state name
?item wdt:P131 ?state .
?item p:P585 [
ps:P585 ?eyear ;
pq:P991 ?member;
].
Filter (year(?eyear) = 2014) .
#optional{?item wdt:P991 ?member .}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
OPTIONAL {
?item rdfs:label ?desc filter (lang(?desc) = "ta").
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?constituency")
v2("?desc"):::projected
v1("?eyear"):::projected
v6("?item"):::projected
v8("?member"):::projected
v4("?name")
v3("?state"):::projected
v7("?statement")
a1((" "))
a2((" "))
c13(["en"]):::literal
c11(["bd:serviceParam"]):::iri
f0[["year-from-dateTime(?eyear) = '2014^^xsd:integer'"]]
f0 --> v1
bind1[/"'wd:Q1445'"/]
bind1 --as--o v3
bind2[/"'wd:Q3532431'"/]
bind2 --as--o v4
bind3[/"'wd:Q3429959'"/]
bind3 --as--o v5
v6 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> v5
v6 --"p:P131"--> v7
v6 --"p:direct/P131"--> v3
a2 --"p:statement/P585"--> v1
a2 --"p:qualifier/P991"--> v8
v6 --"p:P585"--> a2
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v6 -."rdfs:label".-> v2
end