query: #City and town info
  
  SELECT 
    ?item 
    ?itemLabel
    ?fips_code
    ?population 
    ?population_date 
    ?population_methodLabel
    ?countyLabel 
    ?stateLabel 
    ?coordinates 
    ?elevation 
    ?area 
    ?area_date 
    ?website 
    ?climateLabel 
    ?nickname
    ?gmaps_id 
    ?open_street_map_id
    ?open_weather_map_id
    ?facebook_places_id
    ?youtube_id
    ?twitter_user_id
    ?subreddit_id
    ?quora_topic_id
    ?image
    ?flag_image
  WHERE 
  {
    { ?item p:P31/ps:P31/wdt:P279* wd:Q1093829 .} # cities
    UNION { ?item p:P31/ps:P31/wdt:P279* wd:Q15127012 .} # towns
    UNION { ?item p:P31/ps:P31/wdt:P279* wd:Q4946305 .} # boroughs
  #  ?county wdt:P131 wd:Q1261 . # where the county is in colorado
  
    ?item wdt:P131 ?county . #  county
    ?county wdt:P131 ?state . # state
    
    OPTIONAL {?item wdt:P1449 ?nickname} . # nickname
    OPTIONAL {?item wdt:P571 ?inception} . # inception
    OPTIONAL {?item wdt:P625 ?coordinates} . # coordinates
    OPTIONAL {?item wdt:P2044 ?elevation} . # elevation
    OPTIONAL {?item wdt:P856 ?website} . # website
    OPTIONAL {?item wdt:P2564 ?climate} . # climate
    OPTIONAL {?item wdt:P3749 ?gmaps_id} . # gmaps_id
    OPTIONAL {?item wdt:P402 ?open_street_map_id} . # open_street_map_id
    OPTIONAL {?item wdt:P1997 ?facebook_places_id} . # facebook_places_id
    OPTIONAL {?item wdt:P7197 ?open_weather_map_id} . # open_weather_map_id
    OPTIONAL {?item wdt:P774 ?fips_code} . # fips_code
    OPTIONAL {?item wdt:P2397 ?youtube_id} . # youtube_id
    OPTIONAL {?item wdt:P2002 ?twitter_user_id} . # twitter_user_id
    OPTIONAL {?item wdt:P3984 ?subreddit_id} . # subreddit_id
    OPTIONAL {?item wdt:P3417 ?quora_topic_id} . # quora_topic_id
    OPTIONAL {?item wdt:P18 ?image} . # image
    OPTIONAL {?item wdt:P163 ?flag_image} . # flag_image
    
    OPTIONAL {
      ?item p:P1082 ?population_statement.
      ?population_statement ps:P1082 ?population.
      ?population_statement pq:P585 ?population_date.
      ?population_statement pq:P459 ?population_method.
    }
    
    FILTER NOT EXISTS {
      ?item p:P1082/pq:P585 ?population_date_ .
      FILTER (?population_date_ > ?population_date)
    }
    
    OPTIONAL {
      ?item p:P2046 ?area_statement.
      ?area_statement ps:P2046 ?area.
      ?area_statement pq:P585 ?area_date.
    }
    
    FILTER NOT EXISTS {
      ?item p:P2046/pq:P585 ?area_date_ .
      ?item p:P2046/ps:P2046 ?area_ .
      FILTER (
        ?area_date_ > ?area_date && ?area_ > ?area
      )
    }
  
  
    
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } # Helps get the label in your language, if not, then en language
  }