Commit 9a1dd8ff authored by Simantini Shinde's avatar Simantini Shinde
Browse files

Modified column name total

parent e3d5f319
Pipeline #39015 passed with stage
in 1 minute and 27 seconds
......@@ -190,9 +190,9 @@ class JapanDatabase(SpatialiteDatabase):
sql_statement = "CREATE TABLE PopulationDistribution ("
sql_statement += "id INTEGER PRIMARY KEY, "
sql_statement += "district_id INTEGER, "
sql_statement += "total INTEGER, "
sql_statement += "male INTEGER, "
sql_statement += "female INTEGER, "
sql_statement += "total_population INTEGER, "
sql_statement += "male_population INTEGER, "
sql_statement += "female_population INTEGER, "
sql_statement += "number_household INTEGER,"
sql_statement += "population_density REAL)"
self.connection.execute(sql_statement)
......@@ -463,7 +463,11 @@ class JapanDatabase(SpatialiteDatabase):
# Insert the data to the PopulationDistribution table
sql_statement = """
INSERT INTO PopulationDistribution
(district_id, total, male, female, number_household)
(district_id,
total_population,
male_population,
female_population,
number_household)
VALUES (?, ?, ?, ?, ?)
"""
self.cursor.executemany(sql_statement, population_to_db)
......@@ -478,7 +482,7 @@ class JapanDatabase(SpatialiteDatabase):
SET population_density = Q.density
FROM
(
SELECT PopulationDistribution.total/District.area_size AS density,
SELECT PopulationDistribution.total_population/District.area_size AS density,
PopulationDistribution.district_id AS id
FROM PopulationDistribution
INNER JOIN District
......@@ -748,7 +752,7 @@ class JapanDatabase(SpatialiteDatabase):
sum(MappingBuildingExposureToDistrictWithNoInfo.number_building),
AVG(MappingBuildingExposureToDistrictWithNoInfo.number_building)/
MappingBuildingExposureToDistrictWithNoInfo.source_population
* MappingBuildingExposureToDistrictWithNoInfo.[total]
* MappingBuildingExposureToDistrictWithNoInfo.to_update_population
AS to_update_number_building
FROM
(
......@@ -758,14 +762,14 @@ class JapanDatabase(SpatialiteDatabase):
SELECT MappingToDistrictWithNoInfo.id AS to_update_id,
MappingToDistrictWithNoInfo.district_id AS source_id,
MappingToDistrictWithNoInfo.rn,
MappingToDistrictWithNoInfo.[total],
MappingToDistrictWithNoInfo.to_update_population,
MappingToDistrictWithNoInfo.source_population
FROM
(
SELECT DistrictWithNoInformation.id,
DistrictWithNoInformation.district_id,
row_number() OVER (PARTITION BY DistrictWithNoInformation.id) AS rn,
DistrictWithNoInformation.[total],
DistrictWithNoInformation.to_update_population,
DistrictWithNoInformation.source_population
FROM
(
......@@ -775,14 +779,15 @@ class JapanDatabase(SpatialiteDatabase):
SourcePopulationDistribution.population_density
) AS difference,
SourcePopulationDistribution.source_population,
ToUpdatePopulationDistribution.[total]
ToUpdatePopulationDistribution.[total_population]
AS to_update_population
FROM PopulationDistribution AS ToUpdatePopulationDistribution
INNER JOIN District AS D
ON ToUpdatePopulationDistribution.district_id = D.id
CROSS JOIN
(
SELECT DISTINCT B.district_id,
PD.[total] as source_population,
PD.[total_population] as source_population,
PD.population_density
FROM BuildingNumber AS B
INNER JOIN PopulationDistribution AS PD
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment