 			AND r_recurs.parent_region_id IS NOT NULL
 		    )
 
-		SELECT
-			d.id as datapoint_id, d.region_id, d.campaign_id, d.indicator_id, d,value, rt.parent_region_id
+		SELECT DISTINCT
+			d.id as datapoint_id
+			,d.indicator_id
+			,d.campaign_id
+			,d.region_id
+			,d.value
+			,rt.parent_region_id
 		FROM region_tree rt
 		INNER JOIN region r
 		ON r.parent_region_id = rt.parent_region_id

BEGIN


		DROP TABLE IF EXISTS _campaign_indicator;
		CREATE TABLE _campaign_indicator AS
		SELECT DISTINCT campaign_id, indicator_id FROM datapoint d
		WHERE d.cache_job_id = $1;

		DROP TABLE IF EXISTS _to_agg;
		CREATE TABLE _to_agg AS

		WITH RECURSIVE region_tree AS
		    (

		AND ta.campaign_id = d.campaign_id
		AND ta.indicator_id = d.indicator_id;


		--- UPDATE THE REST OF THE DATAPOINT TABLE --

		UPDATE datapoint d
		SET cache_job_id = $1
		WHERE d.id in (
			SELECT datapoint_id
			FROM _to_agg ta
			WHERE ta.datapoint_id IS NOT NULL
		);

		-- UPDATE EXISTING --
		UPDATE agg_datapoint ad
