Commit b2e6a785 authored by Felix Delattre's avatar Felix Delattre
Browse files

Prepare view statement

parent 2a5f44d2
Pipeline #42501 passed with stage
in 59 seconds
DROP TABLE IF EXISTS public.gde_tiles;
CREATE VIEW public.gde_tiles AS SELECT
data_unit_tiles.quadkey AS quadkey,
SUM(
COALESCE(
data_unit_tiles.obm_buildings, 0
) + COALESCE(data_unit_tiles.remainder_buildings, 0)
) AS buildings_total, -- total number of buildings in a tile
SUM(
COALESCE(data_unit_tiles.obm_buildings, 0)
) AS buildings_available, -- total number of GDE buildings in a tile
SUM(
COALESCE(data_unit_tiles.remainder_buildings, 0)
) AS buildings_remainder -- total number of remainder buildings in a tile
FROM data_unit_tiles
WHERE data_unit_tiles.aggregated_source_id = 1
GROUP BY data_unit_tiles.quadkey;
ALTER VIEW public.gde_tiles
OWNER TO postgres;
CREATE VIEW...
SELECT SUM(COALESCE(obm_buildings, 0) + COALESCE(reminder_buildings, 0)) FROM data_unit_tiles WHERE quadkey='%s' AND aggregated_source_id=1; -- total number of buildings in a tile (GDE buildings + remainder buildings)
SELECT SUM(COALESCE(obm_buildings, 0)) FROM data_unit_tiles WHERE quadkey='%s' AND aggregated_source_id=1; -- total number of GDE buildings in a tile
SELECT SUM(COALESCE(reminder_buildings, 0)) FROM data_unit_tiles WHERE quadkey='%s' AND aggregated_source_id=1; -- total number of remainder buildings in a tile
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