Skip to content
Snippets Groups Projects
Commit 870bddcb authored by Riccardo Boero's avatar Riccardo Boero :innocent:
Browse files

fix FACT_population queries to include state-country codes and indexes.

parent e9b4d9e1
No related branches found
No related tags found
No related merge requests found
......@@ -31,8 +31,10 @@ function eu_lau(conn_dict::Dict, selection::Dict)
dftemp = DataFrame()
# iterate over geo objects
for id in geo_id
# Extract the first two characters of id in Julia
id_short = id[1:2]
# prepare query
query = "SELECT POP_"*string(year)*"_01_01 as population FROM eu_lau WHERE CNTR_LAU_CODE = '"*id*"';"
query = "SELECT POP_"*string(year)*"_01_01 as population FROM eu_lau WHERE eu_country = '"*id_short*"' AND CNTR_LAU_CODE = '"*id*"';"
# create connection
conn = establish_connection(conn_dict["host"], conn_dict["user"], conn_dict["password"], conn_dict["database"]; port=conn_dict["port"])
# execute
......@@ -89,8 +91,10 @@ function eu_nuts(conn_dict::Dict, selection::Dict)
dftemp = DataFrame()
# iterate over geo objects
for id in geo_id
# Extract the first two characters of id in Julia
id_short = id[1:2]
# prepare query
query = "SELECT Pop_M+Pop_F as population FROM eu_nuts WHERE GeoID = '"*id*"' AND Year = "*string(year)*";"
query = "SELECT Pop_M+Pop_F as population FROM eu_nuts WHERE eu_country = '"*id_short*"' AND AgeClass = 'TOTAL' AND GeoID = '"*id*"' AND Year = "*string(year)*";"
# create connection
conn = establish_connection(conn_dict["host"], conn_dict["user"], conn_dict["password"], conn_dict["database"]; port=conn_dict["port"])
# execute
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment