query-b4cc2eb05c3b63481159c43273b60254
Get assembly constituencies with changed districts with new and old district tewikilinks during 2022 reorg SELECT DISTINCT ?assembly (CONCAT("[[",STR(?page_titleTE),"]]") as ?assemblytewikilink) (CONCAT("[[",STR(?page_titleTE_dist),"]]") as ?new_dist_tewiki) (CONCAT("[[",STR(?page_titleTE_old_dist),"]]") as ?old_dist_tewiki) WHERE { ?assembly wdt:P31 wd:Q54375413.
{
?assembly p:P131 ?districtnode.
?districtnode ps:P131 ?newdistrict.
?newdistrict wdt:P131 wd:Q1159.
?tewikilink schema:about ?assembly;
schema:isPartOf https://te.wikipedia.org/;
schema:name ?page_titleTE.
?tewikilink_dist schema:about ?newdistrict;
schema:isPartOf https://te.wikipedia.org/;
schema:name ?page_titleTE_dist.
OPTIONAL { ?districtnode pq:P580 ?startdate. }
BIND(IF(BOUND(?startdate), "yes", "no") AS ?startflag_)
BIND(IF(BOUND(?enddate), "yes", "no") AS ?endflag_)
BIND(IF(BOUND(?startdate), YEAR(?startdate), 0 ) AS ?startyear)
BIND(IF(BOUND(?enddate), YEAR(?enddate), 0 ) AS ?endyear)
FILTER (?startflag_ ="yes" && ?endflag_="no" &&year(?startdate) =2022 )
}
{
?assembly p:P131 ?olddistrictnode.
?olddistrictnode ps:P131 ?olddistrict.
?olddistrict wdt:P131 wd:Q1159.
?tewikilink_old_dist schema:about ?olddistrict;
schema:isPartOf https://te.wikipedia.org/;
schema:name ?page_titleTE_old_dist.
OPTIONAL { ?olddistrictnode pq:P582 ?oldenddate. }
BIND(IF(BOUND(?oldenddate), "yes", "no") AS ?oldendflag_)
BIND(IF(BOUND(?oldenddate), YEAR(?oldenddate), 0 ) AS ?oldendyear)
FILTER (?oldendflag_="yes" && (year(?oldenddate) =2022) )
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "te,en". }
}
ORDER BY (?page_titleTE_dist) (?assemblyLabel)
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/>
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#>
#Get assembly constituencies with changed districts with new and old district tewikilinks during 2022 reorg
SELECT DISTINCT ?assembly (CONCAT("[[",STR(?page_titleTE),"]]") as ?assemblytewikilink)
(CONCAT("[[",STR(?page_titleTE_dist),"]]") as ?new_dist_tewiki)
(CONCAT("[[",STR(?page_titleTE_old_dist),"]]") as ?old_dist_tewiki)
WHERE {
?assembly wdt:P31 wd:Q54375413.
{
?assembly p:P131 ?districtnode.
?districtnode ps:P131 ?newdistrict.
?newdistrict wdt:P131 wd:Q1159.
?tewikilink schema:about ?assembly;
schema:isPartOf <https://te.wikipedia.org/>;
schema:name ?page_titleTE.
?tewikilink_dist schema:about ?newdistrict;
schema:isPartOf <https://te.wikipedia.org/>;
schema:name ?page_titleTE_dist.
OPTIONAL { ?districtnode pq:P580 ?startdate. }
BIND(IF(BOUND(?startdate), "yes", "no") AS ?startflag_)
BIND(IF(BOUND(?enddate), "yes", "no") AS ?endflag_)
BIND(IF(BOUND(?startdate), YEAR(?startdate), 0 ) AS ?startyear)
BIND(IF(BOUND(?enddate), YEAR(?enddate), 0 ) AS ?endyear)
FILTER (?startflag_ ="yes" && ?endflag_="no" &&year(?startdate) =2022 )
}
{
?assembly p:P131 ?olddistrictnode.
?olddistrictnode ps:P131 ?olddistrict.
?olddistrict wdt:P131 wd:Q1159.
?tewikilink_old_dist schema:about ?olddistrict;
schema:isPartOf <https://te.wikipedia.org/>;
schema:name ?page_titleTE_old_dist.
OPTIONAL { ?olddistrictnode pq:P582 ?oldenddate. }
BIND(IF(BOUND(?oldenddate), "yes", "no") AS ?oldendflag_)
BIND(IF(BOUND(?oldenddate), YEAR(?oldenddate), 0 ) AS ?oldendyear)
FILTER (?oldendflag_="yes" && (year(?oldenddate) =2022) )
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "te,en". }
}
ORDER BY (?page_titleTE_dist) (?assemblyLabel)