User:Arjunaraoc/assembly, district post 2022 org tewiki article
Jump to navigation
Jump to search
Try it!
#Get assembly constituencies with current district and old district (if available) tewikilinks during 2022 reorg
SELECT DISTINCT ?assembly ?assemblyLabel (CONCAT("[[",STR(?page_titleTE_dist),"]]") as ?new_dist_tewiki) (CONCAT("# [[",STR(?page_titleTE),"]]") as ?assemblytewikilink)
#(CONCAT("[[",STR(?page_titleTE_old_dist),"]]") as ?old_dist_tewiki)
WHERE {
?assembly wdt:P31 wd:Q54375413.
?tewikilink schema:about ?assembly;
schema:isPartOf <https://te.wikipedia.org/>;
schema:name ?page_titleTE.
{
?assembly p:P131 ?districtnode.
?districtnode ps:P131 ?newdistrict.
?newdistrict wdt:P131 wd:Q1159.
?tewikilink_dist schema:about ?newdistrict;
schema:isPartOf <https://te.wikipedia.org/>;
schema:name ?page_titleTE_dist.
OPTIONAL { ?districtnode pq:P580 ?startdate. }
OPTIONAL { ?districtnode pq:P582 ?enddate. }
OPTIONAL { ?assembly wdt:P576 ?defdate.}
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)
BIND(IF(BOUND(?defdate), YEAR(?defdate), 0 ) AS ?defyear)
FILTER ((?startflag_ ="yes" && ?endflag_="no" && ?startyear=2022 )|