Created
November 10, 2016 18:12
-
-
Save HRezaei/3006a895f2ea5200b2463f8ebeda54bd to your computer and use it in GitHub Desktop.
A sample SPARQL query to fetch cities of Iran with population over 10,000
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT ?city ?cityLabel (SAMPLE(?location) AS ?location) (MAX(?population) AS ?population) (SAMPLE(?layer) AS ?layer) | |
WHERE | |
{ | |
?city wdt:P31/wdt:P279* wd:Q515; | |
wdt:P625 ?location; | |
wdt:P1082 ?population. | |
FILTER(?population >= 10000). | |
?city wdt:P17 wd:Q794. | |
BIND( | |
IF(?population < 1000000, "<1M", | |
IF(?population < 2000000, "1M-2M", | |
IF(?population < 5000000, "2M-5M", | |
IF(?population < 10000000, "5M-10M", | |
IF(?population < 20000000, "10M-20M", | |
">20M"))))) | |
AS ?layer). | |
SERVICE wikibase:label { bd:serviceParam wikibase:language "fa". } | |
} | |
GROUP BY ?city ?cityLabel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment