 					total AS pop_size,
 					total * pop_c / pop_y AS pop_curr,
 					lz_code,
-					'normal' AS lz_affected
+					'normal'::text AS lz_affected
 				FROM
 					(
 						SELECT CAST(dc_mdb_code AS varchar(6)) AS dc_mdb_code, sum(pop) AS pop_c

					hh_size,
					lz_affected,
					wg_affected,
					CASE wg_affected WHEN 'grants' THEN 0.8 ELSE 0.2 AS pc_wg_affected,
					threshold,
					deficit
				FROM
					zaf.tbl_ofa_outcomes AS p,
					zaf.tbl_livezones_list AS q,
					(
						SELECT wg_name
						FROM zaf.tbl_wgs, zaf.tbl_wg_names
						WHERE zaf.tbl_wgs.wg_code = zaf.tbl_wg_names.tid
						) AS r
				WHERE
						p.lz_code = q.lz_code
					AND
						p.wg_code = r.wg_code
					AND

				n.lz_affected = m.lz_affected
;


SELECT 'Add in the SAs that have more than one-third of their area intersecting with the hazard area'::text;

EXPLAIN INSERT INTO zaf.demog_sas_ofa_1 (
