query-973808e05a7adb6138e8ab45d07d0115
Query #14: All cities in US that had a population > 30,000 in 2010Query to list US Cities and some info about them.
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#>
PREFIX schema: <http://schema.org/> # remember to add this
SELECT DISTINCT ?city ?cityLabel ?state ?stateLabel ?county ?countyLabel ?pop2010 ?cityfips ?countyfips ?wplink
WHERE {
?city wdt:P31 wd:Q1093829 . # dicity - is a - US City
?city wdt:P131 ?county . # district - is located in the administrative territory of - a region
?county wdt:P131 ?state .
?city wdt:P1082 ?pop2010 .
OPTIONAL {?city wdt:P774 ?cityfips .}
OPTIONAL {?county wdt:P882 ?countyfips .}
FILTER (?pop2010 > 30000) .
OPTIONAL {
?wplink schema:about ?city . # WP link - is about - ?dist
?wplink schema:inLanguage "en" .
?wplink schema:isPartOf <https://en.wikipedia.org/> .
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ASC(?cityLabel) ?countyLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?city"):::projected
v1("?cityLabel"):::projected
v7("?cityfips"):::projected
v5("?county"):::projected
v2("?countyLabel"):::projected
v8("?countyfips"):::projected
v3("?pop2010"):::projected
v6("?state"):::projected
v9("?wplink"):::projected
c10(["en"]):::literal
c3(["wd:Q1093829"]):::iri
c12([https://en.wikipedia.org/]):::iri
c14(["bd:serviceParam"]):::iri
f0[["?pop2010 > '30000^^xsd:integer'"]]
f0 --> v3
v4 --"wdt:P31"--> c3
v4 --"wdt:P131"--> v5
v5 --"wdt:P131"--> v6
v4 --"wdt:P1082"--> v3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P774".-> v7
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v5 -."wdt:P882".-> v8
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v9 -."schema:about".-> v4
v9 --"schema:inLanguage"--> c10
v9 --"schema:isPartOf"--> c12
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c14 --"wikibase:language"--> c10
end