query-38c72acf483792349e4845316cd0cc6c
All cities and towns of India without an STD code mentioned SELECT ?object ?objectLabel ?coord WHERE { ?object wdt:P17 wd:Q668. #India ?object wdt:P31/wdt:P279 wd:Q486972. #Human settlement {?object wdt:P31/wdt:P279 wd:Q515.} UNION {?object wdt:P31/wdt:P279* wd:Q3957.} #Cities and towns. Add more categories, as needed #?object wdt:P625 ?coord. #Location has coordinates. Not necessary yet MINUS {?object wdt:P473 ?localcode.} #Does not have an STD code mentioned SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }
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 bd: <http://www.bigdata.com/rdf#>
#All cities and towns of India without an STD code mentioned
SELECT ?object ?objectLabel ?coord
WHERE {
?object wdt:P17 wd:Q668. #India
?object wdt:P31/wdt:P279* wd:Q486972. #Human settlement
{?object wdt:P31/wdt:P279* wd:Q515.} UNION {?object wdt:P31/wdt:P279* wd:Q3957.} #Cities and towns. Add more categories, as needed
#?object wdt:P625 ?coord. #Location has coordinates. Not necessary yet
MINUS {?object wdt:P473 ?localcode.} #Does not have an STD code mentioned
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Query found at
- https://www.wikidata.org/wiki/User:Soni/sandbox
- https://www.wikidata.org/wiki/Wikidata:WikiProject_India/Tasks
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?localcode")
v1("?object"):::projected
a1((" "))
a2((" "))
a3((" "))
c5(["wd:Q486972"]):::iri
c7(["wd:Q3957"]):::iri
c10(["bd:serviceParam"]):::iri
c6(["wd:Q515"]):::iri
c2(["wd:Q668"]):::iri
c12(["en"]):::literal
v1 --"wdt:P17"--> c2
v1 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c5
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P31"--> a3
a3 --"wdt:P279"--> c7
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c6
end
union0r <== or ==> union0l
end
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
v1 --"wdt:P473"--> v2
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end