     RAISE NOTICE '   + The paging statement: %', paging_statement;
 
      -- prepare statement for the selection
-    execute_statement := 'select  p.project_id AS p_id ,p.title ,p.activity_ids AS a_ids ,pa.orgs AS org ,pf.funding_orgs AS f_orgs ,i.c_name ' ||
+    execute_statement := 'select distinct  p.project_id AS p_id ,p.title ,p.activity_ids AS a_ids ,pa.orgs AS org ,pf.funding_orgs AS f_orgs ,i.c_name ' ||
 			 'from ' ||
 			 -- project/activity
-			 '(select p.project_id, p.title, p.opportunity_id, filter.activity_ids from project p ' ||
+			 '(select p.project_id, p.title, p.opportunity_id, array_agg(filter.activity_id) as activity_ids from project p ' ||
 			 -- filter
-			 'join (SELECT project_id, array_agg(distinct activity_id) as activity_ids, array_agg(distinct taxonomy_id) as taxonomy_ids, array_agg(distinct classification_id) as classification_ids ' ||
-			 ',array_agg(distinct organization_id) as organization_ids FROM taxonomy_lookup GROUP BY project_id) as filter on p.project_id = filter.project_id ';
+			 'join (SELECT project_id, start_date, end_date, activity_id, array_agg(distinct taxonomy_id) as taxonomy_ids, array_agg(distinct classification_id) as classification_ids ' ||
+			 ',array_agg(distinct organization_id) as organization_ids FROM taxonomy_lookup GROUP BY project_id, start_date, end_date, activity_id) as filter on p.project_id = filter.project_id ';
 
     -- append where statements			
     IF dynamic_where1 IS NOT NULL THEN          

	,"updated_date" 	timestamp without time zone 	NOT NULL DEFAULT current_date
	,CONSTRAINT result_id PRIMARY KEY(result_id)
);
-- User
CREATE TABLE "user"
(
	"user_id"		SERIAL				NOT NULL		
	,"first_name" 		character varying(150)
	,"last_name" 		character varying(150)
	,"username"		character varying(255)
	,"email"		character varying(255)
	,"password"		character varying(255)	
	,"active"		boolean				NOT NULL DEFAULT TRUE
	,"retired_by"		integer	
	,"created_by" 		character varying(50)


-- Enable PostGIS (includes raster)
CREATE EXTENSION IF NOT EXISTS postgis; 

-- Enable Encryption
CREATE EXTENSION pgcrypto;

-- Drop Spatial Tables (comment this section out if you have built your spatial tables once)
-- To comment use: ' -- '
