text: drop table if exists `2013 election pres - raw`;
  CREATE TABLE `2013 election pres - raw` (
  	`region` VARCHAR(255) NULL DEFAULT NULL,
  	`district_id` INT(11) NULL DEFAULT NULL,
  	`district_name` VARCHAR(255) NULL DEFAULT NULL,
  	`precinct_id` INT(11) NULL DEFAULT NULL,
  	`attached_precinct_id` INT(10) NULL DEFAULT NULL,
  	`num_possible_voters` INT(11) NULL DEFAULT NULL,
  	`num_special_voters` INT(11) NULL DEFAULT NULL,
  	`num_at_12` INT(11) NULL DEFAULT NULL,
  	`num_at_17` INT(11) NULL DEFAULT NULL,
  	`num_votes` INT(11) NULL DEFAULT NULL,
  	`num_ballots` INT(11) NULL DEFAULT NULL,
  	`num_invalid_votes` INT(11) NULL DEFAULT NULL,
  	`num_valid_votes` INT(11) NULL DEFAULT NULL,
  	`logic_check_fail` INT(11) NULL DEFAULT NULL,
  	`logic_check_difference` INT(11) NULL DEFAULT NULL,
  	`more_ballots_than_votes_flag` INT(11) NULL DEFAULT NULL,
  	`more_ballots_than_votes` INT(11) NULL DEFAULT NULL,
  	`more_votes_than_ballots_flag` INT(11) NULL DEFAULT NULL,
  	`more_votes_than_ballots` INT(11) NULL DEFAULT NULL,
  	`1 - Tamaz Bibiluri` INT(11) NULL DEFAULT NULL,
  	`2 - Giorgi Liluashvili` INT(11) NULL DEFAULT NULL,
  	`3 - Sergo Javakhidze` INT(11) NULL DEFAULT NULL,
  	`4 - Koba Davitashvili` INT(11) NULL DEFAULT NULL,
  	`5 - Davit Bakradze` INT(11) NULL DEFAULT NULL,
  	`6 - Akaki Asatiani` INT(11) NULL DEFAULT NULL,
  	`7 - Nino Chanishvili` INT(11) NULL DEFAULT NULL,
  	`8 - Teimuraz Bobokhidze` INT(11) NULL DEFAULT NULL,
  	`9 - Shalva Natelashvili` INT(11) NULL DEFAULT NULL,
  	`10 - Giorgi Targamadze` INT(11) NULL DEFAULT NULL,
  	`11 - Levan Chachua` INT(11) NULL DEFAULT NULL,
  	`12 - Nestan Kirtadze` INT(11) NULL DEFAULT NULL,
  	`13 - Giorgi Chikhladze` INT(11) NULL DEFAULT NULL,
  	`14 - Nino Burjanadze` INT(11) NULL DEFAULT NULL,
  	`15 - Zurab Kharatishvili` INT(11) NULL DEFAULT NULL,
  	`16 - Mikheil Saluashvili` INT(11) NULL DEFAULT NULL,
  	`17 - Kartlos Gharibashvili` INT(11) NULL DEFAULT NULL,
  	`18 - Mamuka Chokhonelidze` INT(11) NULL DEFAULT NULL,
  	`19 - Avtandil Margiani` INT(11) NULL DEFAULT NULL,
  	`20 - Nugzar Avaliani` INT(11) NULL DEFAULT NULL,
  	`21 - Mamuka Melikishvili` INT(11) NULL DEFAULT NULL,
  	`22 - Teimuraz Mzhavia` INT(11) NULL DEFAULT NULL,
  	`41 - Giorgi Margvelashvili` INT(11) NULL DEFAULT NULL
  )
  COLLATE='utf8_general_ci'
  ENGINE=MyISAM;
  
  drop view if exists `2013 election pres - invalid ballots 0-1`;
  create view `2013 election pres - invalid ballots 0-1` as
  select `raw`.`region` AS `region`,
  `raw`.`district_id` AS `district_id`,
  `raw`.`precinct_id` AS `precinct_id`,
  count(0) AS `num_invalid_ballots` from `2013 election pres - raw` `raw` where (((100 * (`raw`.`num_invalid_votes` / `raw`.`num_votes`)) >= 0) and ((100 * (`raw`.`num_invalid_votes` / `raw`.`num_votes`)) < 1)) group by `raw`.`region`,
  `raw`.`district_id`,
  `raw`.`precinct_id`;
  
  drop view if exists `2013 election pres - invalid ballots 1-3`;
  create view `2013 election pres - invalid ballots 1-3` as
  select `raw`.`region` AS `region`,
  `raw`.`district_id` AS `district_id`,
  `raw`.`precinct_id` AS `precinct_id`,
  count(0) AS `num_invalid_ballots` from `2013 election pres - raw` `raw` where (((100 * (`raw`.`num_invalid_votes` / `raw`.`num_votes`)) >= 1) and ((100 * (`raw`.`num_invalid_votes` / `raw`.`num_votes`)) < 3)) group by `raw`.`region`,
  `raw`.`district_id`,
  `raw`.`precinct_id`;
  
  drop view if exists `2013 election pres - invalid ballots 3-5`;
  create view `2013 election pres - invalid ballots 3-5` as
  select `raw`.`region` AS `region`,
  `raw`.`district_id` AS `district_id`,
  `raw`.`precinct_id` AS `precinct_id`,
  count(0) AS `num_invalid_ballots` from `2013 election pres - raw` `raw` where (((100 * (`raw`.`num_invalid_votes` / `raw`.`num_votes`)) >= 3) and ((100 * (`raw`.`num_invalid_votes` / `raw`.`num_votes`)) < 5)) group by `raw`.`region`,
  `raw`.`district_id`,
  `raw`.`precinct_id`;
  
  drop view if exists `2013 election pres - invalid ballots >5`;
  create view `2013 election pres - invalid ballots >5` as
  select `raw`.`region` AS `region`,
  `raw`.`district_id` AS `district_id`,
  `raw`.`precinct_id` AS `precinct_id`,
  count(0) AS `num_invalid_ballots` from `2013 election pres - raw` `raw` where ((100 * (`raw`.`num_invalid_votes` / `raw`.`num_votes`)) >= 5) group by `raw`.`region`,
  `raw`.`district_id`,
  `raw`.`precinct_id`;
  
  drop view if exists `2013 election pres - vpm 8-12>2`;
  create view `2013 election pres - vpm 8-12>2` as
  select `2013 election pres - raw`.`region` AS `region`,
  `2013 election pres - raw`.`district_id` AS `district_id`,
  `2013 election pres - raw`.`precinct_id` AS `precinct_id`,
  count(0) AS `vpm > 2` from `2013 election pres - raw` where ((`2013 election pres - raw`.`num_at_12` / 240) > 2) group by `2013 election pres - raw`.`region`,
  `2013 election pres - raw`.`district_id`,
  `2013 election pres - raw`.`precinct_id`;
  
  drop view if exists `2013 election pres - vpm 12-17>2`;
  create view `2013 election pres - vpm 12-17>2` as
  select `2013 election pres - raw`.`region` AS `region`,
  `2013 election pres - raw`.`district_id` AS `district_id`,
  `2013 election pres - raw`.`precinct_id` AS `precinct_id`,
  count(0) AS `vpm > 2` from `2013 election pres - raw` where (((`2013 election pres - raw`.`num_at_17` - `2013 election pres - raw`.`num_at_12`) / 300) > 2) group by `2013 election pres - raw`.`region`,
  `2013 election pres - raw`.`district_id`,
  `2013 election pres - raw`.`precinct_id`;
  
  drop view if exists `2013 election pres - vpm 17-20>2`;
  create view `2013 election pres - vpm 17-20>2` as
  select `2013 election pres - raw`.`region` AS `region`,
  `2013 election pres - raw`.`district_id` AS `district_id`,
  `2013 election pres - raw`.`precinct_id` AS `precinct_id`,
  count(0) AS `vpm > 2` from `2013 election pres - raw` where (((`2013 election pres - raw`.`num_votes` - `2013 election pres - raw`.`num_at_17`) / 180) > 2) group by `2013 election pres - raw`.`region`,
  `2013 election pres - raw`.`district_id`,
  `2013 election pres - raw`.`precinct_id`;
  
  
  drop view if exists `2013 election pres - country`;
  create view `2013 election pres - country` as
  select sum(`raw`.`num_possible_voters`) AS `possible voters`,
  sum(`raw`.`num_votes`) AS `total ballots cast`,
  sum(`raw`.`num_valid_votes`) AS `total valid ballots cast`,
  ifnull(sum(`invalid_ballots_01`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 0-1%`,
  ifnull(sum(`invalid_ballots_13`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 1-3%`,
  ifnull(sum(`invalid_ballots_35`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 3-5%`,
  ifnull(sum(`invalid_ballots_>5`.`num_invalid_ballots`),
  0) AS `num invalid ballots >5%`,
  (100 * (sum(`raw`.`num_valid_votes`) / sum(`raw`.`num_possible_voters`))) AS `percent voters voting`,
  sum(`raw`.`logic_check_fail`) AS `num precincts logic fail`,
  (100 * (sum(`raw`.`logic_check_fail`) / count(0))) AS `percent precincts logic fail`,
  (sum(`raw`.`logic_check_difference`) / sum(`raw`.`logic_check_fail`)) AS `avg precinct logic fail difference`,
  sum(`raw`.`more_ballots_than_votes_flag`) AS `num precincts more ballots than votes`,
  (100 * (sum(`raw`.`more_ballots_than_votes_flag`) / count(0))) AS `percent precincts more ballots than votes`,
  (sum(`raw`.`more_ballots_than_votes`) / sum(`raw`.`more_ballots_than_votes_flag`)) AS `avg precinct difference more ballots than votes`,
  sum(`raw`.`more_votes_than_ballots_flag`) AS `num precincts more votes than ballots`,
  (100 * (sum(`raw`.`more_votes_than_ballots_flag`) / count(0))) AS `percent precincts more votes than ballots`,
  (sum(`raw`.`more_votes_than_ballots`) / sum(`raw`.`more_votes_than_ballots_flag`)) AS `avg precinct difference more votes than ballots`,
  sum(`raw`.`num_at_12`) AS `votes 8-12`,
  sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) AS `votes 12-17`,
  sum((`raw`.`num_votes` - `raw`.`num_at_17`)) AS `votes 17-20`,
  (sum(`raw`.`num_at_12`) / count(0)) AS `avg votes/precinct 8-12`,
  (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / count(0)) AS `avg votes/precinct 12-17`,
  (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / count(0)) AS `avg votes/precinct 17-20`,
  (sum(`raw`.`num_at_12`) / 240) AS `vpm 8-12`,
  (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) AS `vpm 12-17`,
  (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 300) AS `vpm 17-20`,
  ((sum(`raw`.`num_at_12`) / 240) / count(0)) AS `avg vpm/precinct 8-12`,
  ((sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) / count(0)) AS `avg vpm/precinct 12-17`,
  ((sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 200) / count(0)) AS `avg vpm/precinct 17-20`,
  ifnull(sum(`vpm1`.`vpm > 2`),
  0) AS `num precincts vpm 8-12 > 2`,
  ifnull(sum(`vpm2`.`vpm > 2`),
  0) AS `num precincts vpm 12-17 > 2`,
  ifnull(sum(`vpm3`.`vpm > 2`),
  0) AS `num precincts vpm 17-20 > 2`,
  ((ifnull(sum(`vpm1`.`vpm > 2`),
  0) + ifnull(sum(`vpm2`.`vpm > 2`),
  0)) + ifnull(sum(`vpm3`.`vpm > 2`),
  0)) AS `num precincts vpm > 2`,
  `precinct_count`.`num_precincts` AS `num_precincts_possible`,
  count(`raw`.`precinct_id`) AS `num_precincts_reported_number`,
  ((100 * count(`raw`.`precinct_id`)) / `precinct_count`.`num_precincts`) AS `num_precincts_reported_percent`,
  sum(`raw`.`1 - Tamaz Bibiluri`) AS `1 - Tamaz Bibiluri count`,
  (100 * (sum(`raw`.`1 - Tamaz Bibiluri`) / sum(`raw`.`num_valid_votes`))) AS `1 - Tamaz Bibiluri`,
  sum(`raw`.`2 - Giorgi Liluashvili`) AS `2 - Giorgi Liluashvili count`,
  (100 * (sum(`raw`.`2 - Giorgi Liluashvili`) / sum(`raw`.`num_valid_votes`))) AS `2 - Giorgi Liluashvili`,
  sum(`raw`.`3 - Sergo Javakhidze`) AS `3 - Sergo Javakhidze count`,
  (100 * (sum(`raw`.`3 - Sergo Javakhidze`) / sum(`raw`.`num_valid_votes`))) AS `3 - Sergo Javakhidze`,
  sum(`raw`.`4 - Koba Davitashvili`) AS `4 - Koba Davitashvili count`,
  (100 * (sum(`raw`.`4 - Koba Davitashvili`) / sum(`raw`.`num_valid_votes`))) AS `4 - Koba Davitashvili`,
  sum(`raw`.`5 - Davit Bakradze`) AS `5 - Davit Bakradze count`,
  (100 * (sum(`raw`.`5 - Davit Bakradze`) / sum(`raw`.`num_valid_votes`))) AS `5 - Davit Bakradze`,
  sum(`raw`.`6 - Akaki Asatiani`) AS `6 - Akaki Asatiani count`,
  (100 * (sum(`raw`.`6 - Akaki Asatiani`) / sum(`raw`.`num_valid_votes`))) AS `6 - Akaki Asatiani`,
  sum(`raw`.`7 - Nino Chanishvili`) AS `7 - Nino Chanishvili count`,
  (100 * (sum(`raw`.`7 - Nino Chanishvili`) / sum(`raw`.`num_valid_votes`))) AS `7 - Nino Chanishvili`,
  sum(`raw`.`8 - Teimuraz Bobokhidze`) AS `8 - Teimuraz Bobokhidze count`,
  (100 * (sum(`raw`.`8 - Teimuraz Bobokhidze`) / sum(`raw`.`num_valid_votes`))) AS `8 - Teimuraz Bobokhidze`,
  sum(`raw`.`9 - Shalva Natelashvili`) AS `9 - Shalva Natelashvili count`,
  (100 * (sum(`raw`.`9 - Shalva Natelashvili`) / sum(`raw`.`num_valid_votes`))) AS `9 - Shalva Natelashvili`,
  sum(`raw`.`10 - Giorgi Targamadze`) AS `10 - Giorgi Targamadze count`,
  (100 * (sum(`raw`.`10 - Giorgi Targamadze`) / sum(`raw`.`num_valid_votes`))) AS `10 - Giorgi Targamadze`,
  sum(`raw`.`11 - Levan Chachua`) AS `11 - Levan Chachua count`,
  (100 * (sum(`raw`.`11 - Levan Chachua`) / sum(`raw`.`num_valid_votes`))) AS `11 - Levan Chachua`,
  sum(`raw`.`12 - Nestan Kirtadze`) AS `12 - Nestan Kirtadze count`,
  (100 * (sum(`raw`.`12 - Nestan Kirtadze`) / sum(`raw`.`num_valid_votes`))) AS `12 - Nestan Kirtadze`,
  sum(`raw`.`13 - Giorgi Chikhladze`) AS `13 - Giorgi Chikhladze count`,
  (100 * (sum(`raw`.`13 - Giorgi Chikhladze`) / sum(`raw`.`num_valid_votes`))) AS `13 - Giorgi Chikhladze`,
  sum(`raw`.`14 - Nino Burjanadze`) AS `14 - Nino Burjanadze count`,
  (100 * (sum(`raw`.`14 - Nino Burjanadze`) / sum(`raw`.`num_valid_votes`))) AS `14 - Nino Burjanadze`,
  sum(`raw`.`15 - Zurab Kharatishvili`) AS `15 - Zurab Kharatishvili count`,
  (100 * (sum(`raw`.`15 - Zurab Kharatishvili`) / sum(`raw`.`num_valid_votes`))) AS `15 - Zurab Kharatishvili`,
  sum(`raw`.`16 - Mikheil Saluashvili`) AS `16 - Mikheil Saluashvili count`,
  (100 * (sum(`raw`.`16 - Mikheil Saluashvili`) / sum(`raw`.`num_valid_votes`))) AS `16 - Mikheil Saluashvili`, 
  sum(`raw`.`17 - Kartlos Gharibashvili`) AS `17 - Kartlos Gharibashvili count`,
  (100 * (sum(`raw`.`17 - Kartlos Gharibashvili`) / sum(`raw`.`num_valid_votes`))) AS `17 - Kartlos Gharibashvili`,
  sum(`raw`.`18 - Mamuka Chokhonelidze`) AS `18 - Mamuka Chokhonelidze count`,
  (100 * (sum(`raw`.`18 - Mamuka Chokhonelidze`) / sum(`raw`.`num_valid_votes`))) AS `18 - Mamuka Chokhonelidze`,
  sum(`raw`.`19 - Avtandil Margiani`) AS `19 - Avtandil Margiani count`,
  (100 * (sum(`raw`.`19 - Avtandil Margiani`) / sum(`raw`.`num_valid_votes`))) AS `19 - Avtandil Margiani`,
  sum(`raw`.`20 - Nugzar Avaliani`) AS `20 - Nugzar Avaliani count`,
  (100 * (sum(`raw`.`20 - Nugzar Avaliani`) / sum(`raw`.`num_valid_votes`))) AS `20 - Nugzar Avaliani`,
  sum(`raw`.`21 - Mamuka Melikishvili`) AS `21 - Mamuka Melikishvili count`,
  (100 * (sum(`raw`.`21 - Mamuka Melikishvili`) / sum(`raw`.`num_valid_votes`))) AS `21 - Mamuka Melikishvili`,
  sum(`raw`.`22 - Teimuraz Mzhavia`) AS `22 - Teimuraz Mzhavia count`,
  (100 * (sum(`raw`.`22 - Teimuraz Mzhavia`) / sum(`raw`.`num_valid_votes`))) AS `22 - Teimuraz Mzhavia`,
  sum(`raw`.`41 - Giorgi Margvelashvili`) AS `41 - Giorgi Margvelashvili count`,
  (100 * (sum(`raw`.`41 - Giorgi Margvelashvili`) / sum(`raw`.`num_valid_votes`))) AS `41 - Giorgi Margvelashvili` 
  from ((((((((`2013 election pres - raw` `raw` left join `2013 election pres - vpm 8-12>2` `vpm1` on(((`raw`.`region` = `vpm1`.`region`) and (`raw`.`district_id` = `vpm1`.`district_id`) and (`raw`.`precinct_id` = `vpm1`.`precinct_id`)))) left join `2013 election pres - vpm 12-17>2` `vpm2` on(((`raw`.`region` = `vpm2`.`region`) and (`raw`.`district_id` = `vpm2`.`district_id`) and (`raw`.`precinct_id` = `vpm2`.`precinct_id`)))) left join `2013 election pres - vpm 17-20>2` `vpm3` on(((`raw`.`region` = convert(`vpm3`.`region` using utf8)) and (`raw`.`district_id` = `vpm3`.`district_id`) and (`raw`.`precinct_id` = `vpm3`.`precinct_id`)))) left join `2013 election pres - invalid ballots 0-1` `invalid_ballots_01` on(((`raw`.`region` = `invalid_ballots_01`.`region`) and (`raw`.`district_id` = `invalid_ballots_01`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_01`.`precinct_id`)))) left join `2013 election pres - invalid ballots 1-3` `invalid_ballots_13` on(((`raw`.`region` = `invalid_ballots_13`.`region`) and (`raw`.`district_id` = `invalid_ballots_13`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_13`.`precinct_id`)))) left join `2013 election pres - invalid ballots 3-5` `invalid_ballots_35` on(((`raw`.`region` = `invalid_ballots_35`.`region`) and (`raw`.`district_id` = `invalid_ballots_35`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_35`.`precinct_id`)))) left join `2013 election pres - invalid ballots >5` `invalid_ballots_>5` on(((`raw`.`region` = `invalid_ballots_>5`.`region`) and (`raw`.`district_id` = `invalid_ballots_>5`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_>5`.`precinct_id`)))) join `2012 election parl - precinct count by country` `precinct_count`);
  
  
  
  drop view if exists `2013 election pres - districts`;
  create view `2013 election pres - districts` as
  select `raw`.`region` AS `region`,
  `raw`.`district_id` AS `district_id`,
  `raw`.`district_name` AS `district_Name`,
  sum(`raw`.`num_possible_voters`) AS `possible voters`,
  sum(`raw`.`num_votes`) AS `total ballots cast`,
  sum(`raw`.`num_valid_votes`) AS `total valid ballots cast`,
  ifnull(sum(`invalid_ballots_01`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 0-1%`,
  ifnull(sum(`invalid_ballots_13`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 1-3%`,
  ifnull(sum(`invalid_ballots_35`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 3-5%`,
  ifnull(sum(`invalid_ballots_>5`.`num_invalid_ballots`),
  0) AS `num invalid ballots >5%`,
  (100 * (sum(`raw`.`num_valid_votes`) / sum(`raw`.`num_possible_voters`))) AS `percent voters voting`,
  sum(`raw`.`logic_check_fail`) AS `num precincts logic fail`,
  (100 * (sum(`raw`.`logic_check_fail`) / count(0))) AS `percent precincts logic fail`,
  (sum(`raw`.`logic_check_difference`) / sum(`raw`.`logic_check_fail`)) AS `avg precinct logic fail difference`,
  sum(`raw`.`more_ballots_than_votes_flag`) AS `num precincts more ballots than votes`,
  (100 * (sum(`raw`.`more_ballots_than_votes_flag`) / count(0))) AS `percent precincts more ballots than votes`,
  (sum(`raw`.`more_ballots_than_votes`) / sum(`raw`.`more_ballots_than_votes_flag`)) AS `avg precinct difference more ballots than votes`,
  sum(`raw`.`more_votes_than_ballots_flag`) AS `num precincts more votes than ballots`,
  (100 * (sum(`raw`.`more_votes_than_ballots_flag`) / count(0))) AS `percent precincts more votes than ballots`,
  (sum(`raw`.`more_votes_than_ballots`) / sum(`raw`.`more_votes_than_ballots_flag`)) AS `avg precinct difference more votes than ballots`,
  sum(`raw`.`num_at_12`) AS `votes 8-12`,
  sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) AS `votes 12-17`,
  sum((`raw`.`num_votes` - `raw`.`num_at_17`)) AS `votes 17-20`,
  (sum(`raw`.`num_at_12`) / count(0)) AS `avg votes/precinct 8-12`,
  (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / count(0)) AS `avg votes/precinct 12-17`,
  (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / count(0)) AS `avg votes/precinct 17-20`,
  (sum(`raw`.`num_at_12`) / 240) AS `vpm 8-12`,
  (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) AS `vpm 12-17`,
  (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 300) AS `vpm 17-20`,
  ((sum(`raw`.`num_at_12`) / 240) / count(0)) AS `avg vpm/precinct 8-12`,
  ((sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) / count(0)) AS `avg vpm/precinct 12-17`,
  ((sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 200) / count(0)) AS `avg vpm/precinct 17-20`,
  ifnull(sum(`vpm1`.`vpm > 2`),
  0) AS `num precincts vpm 8-12 > 2`,
  ifnull(sum(`vpm2`.`vpm > 2`),
  0) AS `num precincts vpm 12-17 > 2`,
  ifnull(sum(`vpm3`.`vpm > 2`),
  0) AS `num precincts vpm 17-20 > 2`,
  ((ifnull(sum(`vpm1`.`vpm > 2`),
  0) + ifnull(sum(`vpm2`.`vpm > 2`),
  0)) + ifnull(sum(`vpm3`.`vpm > 2`),
  0)) AS `num precincts vpm > 2`,
  `precinct_count`.`num_precincts` AS `num_precincts_possible`,
  count(`raw`.`precinct_id`) AS `num_precincts_reported_number`,
  ((100 * count(`raw`.`precinct_id`)) / `precinct_count`.`num_precincts`) AS `num_precincts_reported_percent`,
  sum(`raw`.`1 - Tamaz Bibiluri`) AS `1 - Tamaz Bibiluri count`,
  (100 * (sum(`raw`.`1 - Tamaz Bibiluri`) / sum(`raw`.`num_valid_votes`))) AS `1 - Tamaz Bibiluri`,
  sum(`raw`.`2 - Giorgi Liluashvili`) AS `2 - Giorgi Liluashvili count`,
  (100 * (sum(`raw`.`2 - Giorgi Liluashvili`) / sum(`raw`.`num_valid_votes`))) AS `2 - Giorgi Liluashvili`,
  sum(`raw`.`3 - Sergo Javakhidze`) AS `3 - Sergo Javakhidze count`,
  (100 * (sum(`raw`.`3 - Sergo Javakhidze`) / sum(`raw`.`num_valid_votes`))) AS `3 - Sergo Javakhidze`,
  sum(`raw`.`4 - Koba Davitashvili`) AS `4 - Koba Davitashvili count`,
  (100 * (sum(`raw`.`4 - Koba Davitashvili`) / sum(`raw`.`num_valid_votes`))) AS `4 - Koba Davitashvili`,
  sum(`raw`.`5 - Davit Bakradze`) AS `5 - Davit Bakradze count`,
  (100 * (sum(`raw`.`5 - Davit Bakradze`) / sum(`raw`.`num_valid_votes`))) AS `5 - Davit Bakradze`,
  sum(`raw`.`6 - Akaki Asatiani`) AS `6 - Akaki Asatiani count`,
  (100 * (sum(`raw`.`6 - Akaki Asatiani`) / sum(`raw`.`num_valid_votes`))) AS `6 - Akaki Asatiani`,
  sum(`raw`.`7 - Nino Chanishvili`) AS `7 - Nino Chanishvili count`,
  (100 * (sum(`raw`.`7 - Nino Chanishvili`) / sum(`raw`.`num_valid_votes`))) AS `7 - Nino Chanishvili`,
  sum(`raw`.`8 - Teimuraz Bobokhidze`) AS `8 - Teimuraz Bobokhidze count`,
  (100 * (sum(`raw`.`8 - Teimuraz Bobokhidze`) / sum(`raw`.`num_valid_votes`))) AS `8 - Teimuraz Bobokhidze`,
  sum(`raw`.`9 - Shalva Natelashvili`) AS `9 - Shalva Natelashvili count`,
  (100 * (sum(`raw`.`9 - Shalva Natelashvili`) / sum(`raw`.`num_valid_votes`))) AS `9 - Shalva Natelashvili`,
  sum(`raw`.`10 - Giorgi Targamadze`) AS `10 - Giorgi Targamadze count`,
  (100 * (sum(`raw`.`10 - Giorgi Targamadze`) / sum(`raw`.`num_valid_votes`))) AS `10 - Giorgi Targamadze`,
  sum(`raw`.`11 - Levan Chachua`) AS `11 - Levan Chachua count`,
  (100 * (sum(`raw`.`11 - Levan Chachua`) / sum(`raw`.`num_valid_votes`))) AS `11 - Levan Chachua`,
  sum(`raw`.`12 - Nestan Kirtadze`) AS `12 - Nestan Kirtadze count`,
  (100 * (sum(`raw`.`12 - Nestan Kirtadze`) / sum(`raw`.`num_valid_votes`))) AS `12 - Nestan Kirtadze`,
  sum(`raw`.`13 - Giorgi Chikhladze`) AS `13 - Giorgi Chikhladze count`,
  (100 * (sum(`raw`.`13 - Giorgi Chikhladze`) / sum(`raw`.`num_valid_votes`))) AS `13 - Giorgi Chikhladze`,
  sum(`raw`.`14 - Nino Burjanadze`) AS `14 - Nino Burjanadze count`,
  (100 * (sum(`raw`.`14 - Nino Burjanadze`) / sum(`raw`.`num_valid_votes`))) AS `14 - Nino Burjanadze`,
  sum(`raw`.`15 - Zurab Kharatishvili`) AS `15 - Zurab Kharatishvili count`,
  (100 * (sum(`raw`.`15 - Zurab Kharatishvili`) / sum(`raw`.`num_valid_votes`))) AS `15 - Zurab Kharatishvili`,
  sum(`raw`.`16 - Mikheil Saluashvili`) AS `16 - Mikheil Saluashvili count`,
  (100 * (sum(`raw`.`16 - Mikheil Saluashvili`) / sum(`raw`.`num_valid_votes`))) AS `16 - Mikheil Saluashvili`,
  sum(`raw`.`17 - Kartlos Gharibashvili`) AS `17 - Kartlos Gharibashvili count`,
  (100 * (sum(`raw`.`17 - Kartlos Gharibashvili`) / sum(`raw`.`num_valid_votes`))) AS `17 - Kartlos Gharibashvili`,
  sum(`raw`.`18 - Mamuka Chokhonelidze`) AS `18 - Mamuka Chokhonelidze count`,
  (100 * (sum(`raw`.`18 - Mamuka Chokhonelidze`) / sum(`raw`.`num_valid_votes`))) AS `18 - Mamuka Chokhonelidze`,
  sum(`raw`.`19 - Avtandil Margiani`) AS `19 - Avtandil Margiani count`,
  (100 * (sum(`raw`.`19 - Avtandil Margiani`) / sum(`raw`.`num_valid_votes`))) AS `19 - Avtandil Margiani`,
  sum(`raw`.`20 - Nugzar Avaliani`) AS `20 - Nugzar Avaliani count`,
  (100 * (sum(`raw`.`20 - Nugzar Avaliani`) / sum(`raw`.`num_valid_votes`))) AS `20 - Nugzar Avaliani`,
  sum(`raw`.`21 - Mamuka Melikishvili`) AS `21 - Mamuka Melikishvili count`,
  (100 * (sum(`raw`.`21 - Mamuka Melikishvili`) / sum(`raw`.`num_valid_votes`))) AS `21 - Mamuka Melikishvili`,
  sum(`raw`.`22 - Teimuraz Mzhavia`) AS `22 - Teimuraz Mzhavia count`,
  (100 * (sum(`raw`.`22 - Teimuraz Mzhavia`) / sum(`raw`.`num_valid_votes`))) AS `22 - Teimuraz Mzhavia`,
  sum(`raw`.`41 - Giorgi Margvelashvili`) AS `41 - Giorgi Margvelashvili count`,
  (100 * (sum(`raw`.`41 - Giorgi Margvelashvili`) / sum(`raw`.`num_valid_votes`))) AS `41 - Giorgi Margvelashvili` 
  from ((((((((`2013 election pres - raw` `raw` join `2012 election parl - precinct count by district` `precinct_count` on((`raw`.`district_id` = `precinct_count`.`district_id`))) left join `2013 election pres - vpm 8-12>2` `vpm1` on(((`raw`.`region` = `vpm1`.`region`) and (`raw`.`district_id` = `vpm1`.`district_id`) and (`raw`.`precinct_id` = `vpm1`.`precinct_id`)))) left join `2013 election pres - vpm 12-17>2` `vpm2` on(((`raw`.`region` = `vpm2`.`region`) and (`raw`.`district_id` = `vpm2`.`district_id`) and (`raw`.`precinct_id` = `vpm2`.`precinct_id`)))) left join `2013 election pres - vpm 17-20>2` `vpm3` on(((`raw`.`region` = convert(`vpm3`.`region` using utf8)) and (`raw`.`district_id` = `vpm3`.`district_id`) and (`raw`.`precinct_id` = `vpm3`.`precinct_id`)))) left join `2013 election pres - invalid ballots 0-1` `invalid_ballots_01` on(((`raw`.`region` = `invalid_ballots_01`.`region`) and (`raw`.`district_id` = `invalid_ballots_01`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_01`.`precinct_id`)))) left join `2013 election pres - invalid ballots 1-3` `invalid_ballots_13` on(((`raw`.`region` = `invalid_ballots_13`.`region`) and (`raw`.`district_id` = `invalid_ballots_13`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_13`.`precinct_id`)))) left join `2013 election pres - invalid ballots 3-5` `invalid_ballots_35` on(((`raw`.`region` = `invalid_ballots_35`.`region`) and (`raw`.`district_id` = `invalid_ballots_35`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_35`.`precinct_id`)))) left join `2013 election pres - invalid ballots >5` `invalid_ballots_>5` on(((`raw`.`region` = `invalid_ballots_>5`.`region`) and (`raw`.`district_id` = `invalid_ballots_>5`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_>5`.`precinct_id`)))) where (`raw`.`district_id` not between 1 and 10) group by `raw`.`region`,
  `raw`.`district_name`,
  `raw`.`district_id` union select `raw`.`region` AS `region`,
  999 AS `district_id`,
  `raw`.`region` AS `district_name`,
  sum(`raw`.`num_possible_voters`) AS `possible voters`,
  sum(`raw`.`num_votes`) AS `total ballots cast`,
  sum(`raw`.`num_valid_votes`) AS `total valid ballots cast`,
  ifnull(sum(`invalid_ballots_01`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 0-1%`,
  ifnull(sum(`invalid_ballots_13`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 1-3%`,
  ifnull(sum(`invalid_ballots_35`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 3-5%`,
  ifnull(sum(`invalid_ballots_>5`.`num_invalid_ballots`),
  0) AS `num invalid ballots >5%`,
  (100 * (sum(`raw`.`num_valid_votes`) / sum(`raw`.`num_possible_voters`))) AS `percent voters voting`,
  sum(`raw`.`logic_check_fail`) AS `num precincts logic fail`,
  (100 * (sum(`raw`.`logic_check_fail`) / count(0))) AS `percent precincts logic fail`,
  (sum(`raw`.`logic_check_difference`) / sum(`raw`.`logic_check_fail`)) AS `avg precinct logic fail difference`,
  sum(`raw`.`more_ballots_than_votes_flag`) AS `num precincts more ballots than votes`,
  (100 * (sum(`raw`.`more_ballots_than_votes_flag`) / count(0))) AS `percent precincts more ballots than votes`,
  (sum(`raw`.`more_ballots_than_votes`) / sum(`raw`.`more_ballots_than_votes_flag`)) AS `avg precinct difference more ballots than votes`,
  sum(`raw`.`more_votes_than_ballots_flag`) AS `num precincts more votes than ballots`,
  (100 * (sum(`raw`.`more_votes_than_ballots_flag`) / count(0))) AS `percent precincts more votes than ballots`,
  (sum(`raw`.`more_votes_than_ballots`) / sum(`raw`.`more_votes_than_ballots_flag`)) AS `avg precinct difference more votes than ballots`,
  sum(`raw`.`num_at_12`) AS `votes 8-12`,
  sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) AS `votes 12-17`,
  sum((`raw`.`num_votes` - `raw`.`num_at_17`)) AS `votes 17-20`,
  (sum(`raw`.`num_at_12`) / count(0)) AS `avg votes/precinct 8-12`,
  (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / count(0)) AS `avg votes/precinct 12-17`,
  (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / count(0)) AS `avg votes/precinct 17-20`,
  (sum(`raw`.`num_at_12`) / 240) AS `vpm 8-12`,
  (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) AS `vpm 12-17`,
  (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 300) AS `vpm 17-20`,
  ((sum(`raw`.`num_at_12`) / 240) / count(0)) AS `avg vpm/precinct 8-12`,
  ((sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) / count(0)) AS `avg vpm/precinct 12-17`,
  ((sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 200) / count(0)) AS `avg vpm/precinct 17-20`,
  ifnull(sum(`vpm1`.`vpm > 2`),
  0) AS `num precincts vpm 8-12 > 2`,
  ifnull(sum(`vpm2`.`vpm > 2`),
  0) AS `num precincts vpm 12-17 > 2`,
  ifnull(sum(`vpm3`.`vpm > 2`),
  0) AS `num precincts vpm 17-20 > 2`,
  ((ifnull(sum(`vpm1`.`vpm > 2`),
  0) + ifnull(sum(`vpm2`.`vpm > 2`),
  0)) + ifnull(sum(`vpm3`.`vpm > 2`),
  0)) AS `num precincts vpm > 2`,
  `precinct_count`.`num_precincts` AS `num_precincts_possible`,
  count(`raw`.`precinct_id`) AS `num_precincts_reported_number`,
  ((100 * count(`raw`.`precinct_id`)) / `precinct_count`.`num_precincts`) AS `num_precincts_reported_percent`,
  sum(`raw`.`1 - Tamaz Bibiluri`) AS `1 - Tamaz Bibiluri count`,
  (100 * (sum(`raw`.`1 - Tamaz Bibiluri`) / sum(`raw`.`num_valid_votes`))) AS `1 - Tamaz Bibiluri`,
  sum(`raw`.`2 - Giorgi Liluashvili`) AS `2 - Giorgi Liluashvili count`,
  (100 * (sum(`raw`.`2 - Giorgi Liluashvili`) / sum(`raw`.`num_valid_votes`))) AS `2 - Giorgi Liluashvili`,
  sum(`raw`.`3 - Sergo Javakhidze`) AS `3 - Sergo Javakhidze count`,
  (100 * (sum(`raw`.`3 - Sergo Javakhidze`) / sum(`raw`.`num_valid_votes`))) AS `3 - Sergo Javakhidze`,
  sum(`raw`.`4 - Koba Davitashvili`) AS `4 - Koba Davitashvili count`,
  (100 * (sum(`raw`.`4 - Koba Davitashvili`) / sum(`raw`.`num_valid_votes`))) AS `4 - Koba Davitashvili`,
  sum(`raw`.`5 - Davit Bakradze`) AS `5 - Davit Bakradze count`,
  (100 * (sum(`raw`.`5 - Davit Bakradze`) / sum(`raw`.`num_valid_votes`))) AS `5 - Davit Bakradze`,
  sum(`raw`.`6 - Akaki Asatiani`) AS `6 - Akaki Asatiani count`,
  (100 * (sum(`raw`.`6 - Akaki Asatiani`) / sum(`raw`.`num_valid_votes`))) AS `6 - Akaki Asatiani`,
  sum(`raw`.`7 - Nino Chanishvili`) AS `7 - Nino Chanishvili count`,
  (100 * (sum(`raw`.`7 - Nino Chanishvili`) / sum(`raw`.`num_valid_votes`))) AS `7 - Nino Chanishvili`,
  sum(`raw`.`8 - Teimuraz Bobokhidze`) AS `8 - Teimuraz Bobokhidze count`,
  (100 * (sum(`raw`.`8 - Teimuraz Bobokhidze`) / sum(`raw`.`num_valid_votes`))) AS `8 - Teimuraz Bobokhidze`,
  sum(`raw`.`9 - Shalva Natelashvili`) AS `9 - Shalva Natelashvili count`,
  (100 * (sum(`raw`.`9 - Shalva Natelashvili`) / sum(`raw`.`num_valid_votes`))) AS `9 - Shalva Natelashvili`,
  sum(`raw`.`10 - Giorgi Targamadze`) AS `10 - Giorgi Targamadze count`,
  (100 * (sum(`raw`.`10 - Giorgi Targamadze`) / sum(`raw`.`num_valid_votes`))) AS `10 - Giorgi Targamadze`,
  sum(`raw`.`11 - Levan Chachua`) AS `11 - Levan Chachua count`,
  (100 * (sum(`raw`.`11 - Levan Chachua`) / sum(`raw`.`num_valid_votes`))) AS `11 - Levan Chachua`,
  sum(`raw`.`12 - Nestan Kirtadze`) AS `12 - Nestan Kirtadze count`,
  (100 * (sum(`raw`.`12 - Nestan Kirtadze`) / sum(`raw`.`num_valid_votes`))) AS `12 - Nestan Kirtadze`,
  sum(`raw`.`13 - Giorgi Chikhladze`) AS `13 - Giorgi Chikhladze count`,
  (100 * (sum(`raw`.`13 - Giorgi Chikhladze`) / sum(`raw`.`num_valid_votes`))) AS `13 - Giorgi Chikhladze`,
  sum(`raw`.`14 - Nino Burjanadze`) AS `14 - Nino Burjanadze count`,
  (100 * (sum(`raw`.`14 - Nino Burjanadze`) / sum(`raw`.`num_valid_votes`))) AS `14 - Nino Burjanadze`,
  sum(`raw`.`15 - Zurab Kharatishvili`) AS `15 - Zurab Kharatishvili count`,
  (100 * (sum(`raw`.`15 - Zurab Kharatishvili`) / sum(`raw`.`num_valid_votes`))) AS `15 - Zurab Kharatishvili`,
  sum(`raw`.`16 - Mikheil Saluashvili`) AS `16 - Mikheil Saluashvili count`,
  (100 * (sum(`raw`.`16 - Mikheil Saluashvili`) / sum(`raw`.`num_valid_votes`))) AS `16 - Mikheil Saluashvili`,
  sum(`raw`.`17 - Kartlos Gharibashvili`) AS `17 - Kartlos Gharibashvili count`,
  (100 * (sum(`raw`.`17 - Kartlos Gharibashvili`) / sum(`raw`.`num_valid_votes`))) AS `17 - Kartlos Gharibashvili`,
  sum(`raw`.`18 - Mamuka Chokhonelidze`) AS `18 - Mamuka Chokhonelidze count`,
  (100 * (sum(`raw`.`18 - Mamuka Chokhonelidze`) / sum(`raw`.`num_valid_votes`))) AS `18 - Mamuka Chokhonelidze`,
  sum(`raw`.`19 - Avtandil Margiani`) AS `19 - Avtandil Margiani count`,
  (100 * (sum(`raw`.`19 - Avtandil Margiani`) / sum(`raw`.`num_valid_votes`))) AS `19 - Avtandil Margiani`,
  sum(`raw`.`20 - Nugzar Avaliani`) AS `20 - Nugzar Avaliani count`,
  (100 * (sum(`raw`.`20 - Nugzar Avaliani`) / sum(`raw`.`num_valid_votes`))) AS `20 - Nugzar Avaliani`,
  sum(`raw`.`21 - Mamuka Melikishvili`) AS `21 - Mamuka Melikishvili count`,
  (100 * (sum(`raw`.`21 - Mamuka Melikishvili`) / sum(`raw`.`num_valid_votes`))) AS `21 - Mamuka Melikishvili`,
  sum(`raw`.`22 - Teimuraz Mzhavia`) AS `22 - Teimuraz Mzhavia count`,
  (100 * (sum(`raw`.`22 - Teimuraz Mzhavia`) / sum(`raw`.`num_valid_votes`))) AS `22 - Teimuraz Mzhavia`,
  sum(`raw`.`41 - Giorgi Margvelashvili`) AS `41 - Giorgi Margvelashvili count`,
  (100 * (sum(`raw`.`41 - Giorgi Margvelashvili`) / sum(`raw`.`num_valid_votes`))) AS `41 - Giorgi Margvelashvili` 
  from ((((((((`2013 election pres - raw` `raw` join `2012 election parl - precinct count by region` `precinct_count` on((`raw`.`region` = `precinct_count`.`region`))) left join `2013 election pres - vpm 8-12>2` `vpm1` on(((`raw`.`region` = `vpm1`.`region`) and (`raw`.`district_id` = `vpm1`.`district_id`) and (`raw`.`precinct_id` = `vpm1`.`precinct_id`)))) left join `2013 election pres - vpm 12-17>2` `vpm2` on(((`raw`.`region` = `vpm2`.`region`) and (`raw`.`district_id` = `vpm2`.`district_id`) and (`raw`.`precinct_id` = `vpm2`.`precinct_id`)))) left join `2013 election pres - vpm 17-20>2` `vpm3` on(((`raw`.`region` = convert(`vpm3`.`region` using utf8)) and (`raw`.`district_id` = `vpm3`.`district_id`) and (`raw`.`precinct_id` = `vpm3`.`precinct_id`)))) left join `2013 election pres - invalid ballots 0-1` `invalid_ballots_01` on(((`raw`.`region` = `invalid_ballots_01`.`region`) and (`raw`.`district_id` = `invalid_ballots_01`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_01`.`precinct_id`)))) left join `2013 election pres - invalid ballots 1-3` `invalid_ballots_13` on(((`raw`.`region` = `invalid_ballots_13`.`region`) and (`raw`.`district_id` = `invalid_ballots_13`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_13`.`precinct_id`)))) left join `2013 election pres - invalid ballots 3-5` `invalid_ballots_35` on(((`raw`.`region` = `invalid_ballots_35`.`region`) and (`raw`.`district_id` = `invalid_ballots_35`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_35`.`precinct_id`)))) left join `2013 election pres - invalid ballots >5` `invalid_ballots_>5` on(((`raw`.`region` = `invalid_ballots_>5`.`region`) and (`raw`.`district_id` = `invalid_ballots_>5`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_>5`.`precinct_id`)))) where (`raw`.`district_id` between 1 and 10) group by `raw`.`region`;
  
  
  
  
  drop view if exists `2013 election pres - precincts`;
  create view `2013 election pres - precincts` as
  select `raw`.`region` AS `region`,
  `raw`.`district_id` AS `district_id`,
  `raw`.`district_name` AS `district_Name`,
  `raw`.`precinct_id` AS `precinct_id`,
  concat(cast(`raw`.`district_id` as char charset utf8),
  '-',
  cast(`raw`.`precinct_id` as char charset utf8)) AS `precinct_name`,
  `raw`.`num_possible_voters` AS `possible voters`,
  `raw`.`num_votes` AS `total ballots cast`,
  `raw`.`num_valid_votes` AS `total valid ballots cast`,
  (100 * (`raw`.`num_invalid_votes` / `raw`.`num_votes`)) AS `percent invalid ballots`,
  (100 * (`raw`.`num_valid_votes` / `raw`.`num_possible_voters`)) AS `percent voters voting`,
  `raw`.`logic_check_fail` AS `logic_check_fail`,
  `raw`.`logic_check_difference` AS `logic_check_difference`,
  `raw`.`more_ballots_than_votes_flag` as `more_ballots_than_votes_flag`,
  `raw`.`more_ballots_than_votes` as `more_ballots_than_votes`,
  `raw`.`more_votes_than_ballots_flag` as `more_votes_than_ballots_flag`,
  `raw`.`more_votes_than_ballots` as `more_votes_than_ballots`,
  `raw`.`num_at_12` AS `votes 8-12`,
  (`raw`.`num_at_17` - `raw`.`num_at_12`) AS `votes 12-17`,
  (`raw`.`num_votes` - `raw`.`num_at_17`) AS `votes 17-20`,
  (`raw`.`num_at_12` / 240) AS `vpm 8-12`,
  ((`raw`.`num_at_17` - `raw`.`num_at_12`) / 300) AS `vpm 12-17`,
  ((`raw`.`num_votes` - `raw`.`num_at_17`) / 180) AS `vpm 17-20`,
  `raw`.`1 - Tamaz Bibiluri` AS `1 - Tamaz Bibiluri count`,
  (100 * (`raw`.`1 - Tamaz Bibiluri` / `raw`.`num_valid_votes`)) AS `1 - Tamaz Bibiluri`,
  `raw`.`2 - Giorgi Liluashvili` AS `2 - Giorgi Liluashvili count`,
  (100 * (`raw`.`2 - Giorgi Liluashvili` / `raw`.`num_valid_votes`)) AS `2 - Giorgi Liluashvili`,
  `raw`.`3 - Sergo Javakhidze` AS `3 - Sergo Javakhidze count`,
  (100 * (`raw`.`3 - Sergo Javakhidze` / `raw`.`num_valid_votes`)) AS `3 - Sergo Javakhidze`,
  `raw`.`4 - Koba Davitashvili` AS `4 - Koba Davitashvili count`,
  (100 * (`raw`.`4 - Koba Davitashvili` / `raw`.`num_valid_votes`)) AS `4 - Koba Davitashvili`,
  `raw`.`5 - Davit Bakradze` AS `5 - Davit Bakradze count`,
  (100 * (`raw`.`5 - Davit Bakradze` / `raw`.`num_valid_votes`)) AS `5 - Davit Bakradze`,
  `raw`.`6 - Akaki Asatiani` AS `6 - Akaki Asatiani count`,
  (100 * (`raw`.`6 - Akaki Asatiani` / `raw`.`num_valid_votes`)) AS `6 - Akaki Asatiani`,
  `raw`.`7 - Nino Chanishvili` AS `7 - Nino Chanishvili count`,
  (100 * (`raw`.`7 - Nino Chanishvili` / `raw`.`num_valid_votes`)) AS `7 - Nino Chanishvili`,
  `raw`.`8 - Teimuraz Bobokhidze` AS `8 - Teimuraz Bobokhidze count`,
  (100 * (`raw`.`8 - Teimuraz Bobokhidze` / `raw`.`num_valid_votes`)) AS `8 - Teimuraz Bobokhidze`,
  `raw`.`9 - Shalva Natelashvili` AS `9 - Shalva Natelashvili count`,
  (100 * (`raw`.`9 - Shalva Natelashvili` / `raw`.`num_valid_votes`)) AS `9 - Shalva Natelashvili`,
  `raw`.`10 - Giorgi Targamadze` AS `10 - Giorgi Targamadze count`,
  (100 * (`raw`.`10 - Giorgi Targamadze` / `raw`.`num_valid_votes`)) AS `10 - Giorgi Targamadze`,
  `raw`.`11 - Levan Chachua` AS `11 - Levan Chachua count`,
  (100 * (`raw`.`11 - Levan Chachua` / `raw`.`num_valid_votes`)) AS `11 - Levan Chachua`,
  `raw`.`12 - Nestan Kirtadze` AS `12 - Nestan Kirtadze count`,
  (100 * (`raw`.`12 - Nestan Kirtadze` / `raw`.`num_valid_votes`)) AS `12 - Nestan Kirtadze`,
  `raw`.`13 - Giorgi Chikhladze` AS `13 - Giorgi Chikhladze count`,
  (100 * (`raw`.`13 - Giorgi Chikhladze` / `raw`.`num_valid_votes`)) AS `13 - Giorgi Chikhladze`,
  `raw`.`14 - Nino Burjanadze` AS `14 - Nino Burjanadze count`,
  (100 * (`raw`.`14 - Nino Burjanadze` / `raw`.`num_valid_votes`)) AS `14 - Nino Burjanadze`,
  `raw`.`15 - Zurab Kharatishvili` AS `15 - Zurab Kharatishvili count`,
  (100 * (`raw`.`15 - Zurab Kharatishvili` / `raw`.`num_valid_votes`)) AS `15 - Zurab Kharatishvili`,
  `raw`.`16 - Mikheil Saluashvili` AS `16 - Mikheil Saluashvili count`,
  (100 * (`raw`.`16 - Mikheil Saluashvili` / `raw`.`num_valid_votes`)) AS `16 - Mikheil Saluashvili`,
  `raw`.`17 - Kartlos Gharibashvili` AS `17 - Kartlos Gharibashvili count`,
  (100 * (`raw`.`17 - Kartlos Gharibashvili` / `raw`.`num_valid_votes`)) AS `17 - Kartlos Gharibashvili`,
  `raw`.`18 - Mamuka Chokhonelidze` AS `18 - Mamuka Chokhonelidze count`,
  (100 * (`raw`.`18 - Mamuka Chokhonelidze` / `raw`.`num_valid_votes`)) AS `18 - Mamuka Chokhonelidze`,
  `raw`.`19 - Avtandil Margiani` AS `19 - Avtandil Margiani count`,
  (100 * (`raw`.`19 - Avtandil Margiani` / `raw`.`num_valid_votes`)) AS `19 - Avtandil Margiani`,
  `raw`.`20 - Nugzar Avaliani` AS `20 - Nugzar Avaliani count`,
  (100 * (`raw`.`20 - Nugzar Avaliani` / `raw`.`num_valid_votes`)) AS `20 - Nugzar Avaliani`,
  `raw`.`21 - Mamuka Melikishvili` AS `21 - Mamuka Melikishvili count`,
  (100 * (`raw`.`21 - Mamuka Melikishvili` / `raw`.`num_valid_votes`)) AS `21 - Mamuka Melikishvili`,
  `raw`.`22 - Teimuraz Mzhavia` AS `22 - Teimuraz Mzhavia count`,
  (100 * (`raw`.`22 - Teimuraz Mzhavia` / `raw`.`num_valid_votes`)) AS `22 - Teimuraz Mzhavia`,
  `raw`.`41 - Giorgi Margvelashvili` AS `41 - Giorgi Margvelashvili count`,
  (100 * (`raw`.`41 - Giorgi Margvelashvili` / `raw`.`num_valid_votes`)) AS `41 - Giorgi Margvelashvili` 
  from `2013 election pres - raw` `raw` where (`raw`.`district_id` not between 1 and 10);
  
  
  
  
  drop view if exists `2013 election pres - region`;
  create view `2013 election pres - region` as
  select `raw`.`region` AS `region`,
  sum(`raw`.`num_possible_voters`) AS `possible voters`,
  sum(`raw`.`num_votes`) AS `total ballots cast`,
  sum(`raw`.`num_valid_votes`) AS `total valid ballots cast`,
  ifnull(sum(`invalid_ballots_01`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 0-1%`,
  ifnull(sum(`invalid_ballots_13`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 1-3%`,
  ifnull(sum(`invalid_ballots_35`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 3-5%`,
  ifnull(sum(`invalid_ballots_>5`.`num_invalid_ballots`),
  0) AS `num invalid ballots >5%`,
  (100 * (sum(`raw`.`num_valid_votes`) / sum(`raw`.`num_possible_voters`))) AS `percent voters voting`,
  sum(`raw`.`logic_check_fail`) AS `num precincts logic fail`,
  (100 * (sum(`raw`.`logic_check_fail`) / count(0))) AS `percent precincts logic fail`,
  (sum(`raw`.`logic_check_difference`) / sum(`raw`.`logic_check_fail`)) AS `avg precinct logic fail difference`,
  sum(`raw`.`more_ballots_than_votes_flag`) AS `num precincts more ballots than votes`,
  (100 * (sum(`raw`.`more_ballots_than_votes_flag`) / count(0))) AS `percent precincts more ballots than votes`,
  (sum(`raw`.`more_ballots_than_votes`) / sum(`raw`.`more_ballots_than_votes_flag`)) AS `avg precinct difference more ballots than votes`,
  sum(`raw`.`more_votes_than_ballots_flag`) AS `num precincts more votes than ballots`,
  (100 * (sum(`raw`.`more_votes_than_ballots_flag`) / count(0))) AS `percent precincts more votes than ballots`,
  (sum(`raw`.`more_votes_than_ballots`) / sum(`raw`.`more_votes_than_ballots_flag`)) AS `avg precinct difference more votes than ballots`,
  sum(`raw`.`num_at_12`) AS `votes 8-12`,
  sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) AS `votes 12-17`,
  sum((`raw`.`num_votes` - `raw`.`num_at_17`)) AS `votes 17-20`,
  (sum(`raw`.`num_at_12`) / count(0)) AS `avg votes/precinct 8-12`,
  (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / count(0)) AS `avg votes/precinct 12-17`,
  (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / count(0)) AS `avg votes/precinct 17-20`,
  (sum(`raw`.`num_at_12`) / 240) AS `vpm 8-12`,
  (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) AS `vpm 12-17`,
  (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 300) AS `vpm 17-20`,
  ((sum(`raw`.`num_at_12`) / 240) / count(0)) AS `avg vpm/precinct 8-12`,
  ((sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) / count(0)) AS `avg vpm/precinct 12-17`,
  ((sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 200) / count(0)) AS `avg vpm/precinct 17-20`,
  ifnull(sum(`vpm1`.`vpm > 2`),
  0) AS `num precincts vpm 8-12 > 2`,
  ifnull(sum(`vpm2`.`vpm > 2`),
  0) AS `num precincts vpm 12-17 > 2`,
  ifnull(sum(`vpm3`.`vpm > 2`),
  0) AS `num precincts vpm 17-20 > 2`,
  ((ifnull(sum(`vpm1`.`vpm > 2`),
  0) + ifnull(sum(`vpm2`.`vpm > 2`),
  0)) + ifnull(sum(`vpm3`.`vpm > 2`),
  0)) AS `num precincts vpm > 2`,
  `precinct_count`.`num_precincts` AS `num_precincts_possible`,
  count(`raw`.`precinct_id`) AS `num_precincts_reported_number`,
  ((100 * count(`raw`.`precinct_id`)) / `precinct_count`.`num_precincts`) AS `num_precincts_reported_percent`,
  sum(`raw`.`1 - Tamaz Bibiluri`) AS `1 - Tamaz Bibiluri count`,
  (100 * (sum(`raw`.`1 - Tamaz Bibiluri`) / sum(`raw`.`num_valid_votes`))) AS `1 - Tamaz Bibiluri`,
  sum(`raw`.`2 - Giorgi Liluashvili`) AS `2 - Giorgi Liluashvili count`,
  (100 * (sum(`raw`.`2 - Giorgi Liluashvili`) / sum(`raw`.`num_valid_votes`))) AS `2 - Giorgi Liluashvili`,
  sum(`raw`.`3 - Sergo Javakhidze`) AS `3 - Sergo Javakhidze count`,
  (100 * (sum(`raw`.`3 - Sergo Javakhidze`) / sum(`raw`.`num_valid_votes`))) AS `3 - Sergo Javakhidze`,
  sum(`raw`.`4 - Koba Davitashvili`) AS `4 - Koba Davitashvili count`,
  (100 * (sum(`raw`.`4 - Koba Davitashvili`) / sum(`raw`.`num_valid_votes`))) AS `4 - Koba Davitashvili`,
  sum(`raw`.`5 - Davit Bakradze`) AS `5 - Davit Bakradze count`,
  (100 * (sum(`raw`.`5 - Davit Bakradze`) / sum(`raw`.`num_valid_votes`))) AS `5 - Davit Bakradze`,
  sum(`raw`.`6 - Akaki Asatiani`) AS `6 - Akaki Asatiani count`,
  (100 * (sum(`raw`.`6 - Akaki Asatiani`) / sum(`raw`.`num_valid_votes`))) AS `6 - Akaki Asatiani`,
  sum(`raw`.`7 - Nino Chanishvili`) AS `7 - Nino Chanishvili count`,
  (100 * (sum(`raw`.`7 - Nino Chanishvili`) / sum(`raw`.`num_valid_votes`))) AS `7 - Nino Chanishvili`,
  sum(`raw`.`8 - Teimuraz Bobokhidze`) AS `8 - Teimuraz Bobokhidze count`,
  (100 * (sum(`raw`.`8 - Teimuraz Bobokhidze`) / sum(`raw`.`num_valid_votes`))) AS `8 - Teimuraz Bobokhidze`,
  sum(`raw`.`9 - Shalva Natelashvili`) AS `9 - Shalva Natelashvili count`,
  (100 * (sum(`raw`.`9 - Shalva Natelashvili`) / sum(`raw`.`num_valid_votes`))) AS `9 - Shalva Natelashvili`,
  sum(`raw`.`10 - Giorgi Targamadze`) AS `10 - Giorgi Targamadze count`,
  (100 * (sum(`raw`.`10 - Giorgi Targamadze`) / sum(`raw`.`num_valid_votes`))) AS `10 - Giorgi Targamadze`,
  sum(`raw`.`11 - Levan Chachua`) AS `11 - Levan Chachua count`,
  (100 * (sum(`raw`.`11 - Levan Chachua`) / sum(`raw`.`num_valid_votes`))) AS `11 - Levan Chachua`,
  sum(`raw`.`12 - Nestan Kirtadze`) AS `12 - Nestan Kirtadze count`,
  (100 * (sum(`raw`.`12 - Nestan Kirtadze`) / sum(`raw`.`num_valid_votes`))) AS `12 - Nestan Kirtadze`,
  sum(`raw`.`13 - Giorgi Chikhladze`) AS `13 - Giorgi Chikhladze count`,
  (100 * (sum(`raw`.`13 - Giorgi Chikhladze`) / sum(`raw`.`num_valid_votes`))) AS `13 - Giorgi Chikhladze`,
  sum(`raw`.`14 - Nino Burjanadze`) AS `14 - Nino Burjanadze count`,
  (100 * (sum(`raw`.`14 - Nino Burjanadze`) / sum(`raw`.`num_valid_votes`))) AS `14 - Nino Burjanadze`,
  sum(`raw`.`15 - Zurab Kharatishvili`) AS `15 - Zurab Kharatishvili count`,
  (100 * (sum(`raw`.`15 - Zurab Kharatishvili`) / sum(`raw`.`num_valid_votes`))) AS `15 - Zurab Kharatishvili`,
  sum(`raw`.`16 - Mikheil Saluashvili`) AS `16 - Mikheil Saluashvili count`,
  (100 * (sum(`raw`.`16 - Mikheil Saluashvili`) / sum(`raw`.`num_valid_votes`))) AS `16 - Mikheil Saluashvili`,
  sum(`raw`.`17 - Kartlos Gharibashvili`) AS `17 - Kartlos Gharibashvili count`,
  (100 * (sum(`raw`.`17 - Kartlos Gharibashvili`) / sum(`raw`.`num_valid_votes`))) AS `17 - Kartlos Gharibashvili`,
  sum(`raw`.`18 - Mamuka Chokhonelidze`) AS `18 - Mamuka Chokhonelidze count`,
  (100 * (sum(`raw`.`18 - Mamuka Chokhonelidze`) / sum(`raw`.`num_valid_votes`))) AS `18 - Mamuka Chokhonelidze`,
  sum(`raw`.`19 - Avtandil Margiani`) AS `19 - Avtandil Margiani count`,
  (100 * (sum(`raw`.`19 - Avtandil Margiani`) / sum(`raw`.`num_valid_votes`))) AS `19 - Avtandil Margiani`,
  sum(`raw`.`20 - Nugzar Avaliani`) AS `20 - Nugzar Avaliani count`,
  (100 * (sum(`raw`.`20 - Nugzar Avaliani`) / sum(`raw`.`num_valid_votes`))) AS `20 - Nugzar Avaliani`,
  sum(`raw`.`21 - Mamuka Melikishvili`) AS `21 - Mamuka Melikishvili count`,
  (100 * (sum(`raw`.`21 - Mamuka Melikishvili`) / sum(`raw`.`num_valid_votes`))) AS `21 - Mamuka Melikishvili`,
  sum(`raw`.`22 - Teimuraz Mzhavia`) AS `22 - Teimuraz Mzhavia count`,
  (100 * (sum(`raw`.`22 - Teimuraz Mzhavia`) / sum(`raw`.`num_valid_votes`))) AS `22 - Teimuraz Mzhavia`,
  sum(`raw`.`41 - Giorgi Margvelashvili`) AS `41 - Giorgi Margvelashvili count`,
  (100 * (sum(`raw`.`41 - Giorgi Margvelashvili`) / sum(`raw`.`num_valid_votes`))) AS `41 - Giorgi Margvelashvili` 
  from ((((((((`2013 election pres - raw` `raw` join `2012 election parl - precinct count by region` `precinct_count` on((`raw`.`region` = `precinct_count`.`region`))) left join `2013 election pres - vpm 8-12>2` `vpm1` on(((`raw`.`region` = `vpm1`.`region`) and (`raw`.`district_id` = `vpm1`.`district_id`) and (`raw`.`precinct_id` = `vpm1`.`precinct_id`)))) left join `2013 election pres - vpm 12-17>2` `vpm2` on(((`raw`.`region` = `vpm2`.`region`) and (`raw`.`district_id` = `vpm2`.`district_id`) and (`raw`.`precinct_id` = `vpm2`.`precinct_id`)))) left join `2013 election pres - vpm 17-20>2` `vpm3` on(((`raw`.`region` = convert(`vpm3`.`region` using utf8)) and (`raw`.`district_id` = `vpm3`.`district_id`) and (`raw`.`precinct_id` = `vpm3`.`precinct_id`)))) left join `2013 election pres - invalid ballots 0-1` `invalid_ballots_01` on(((`raw`.`region` = `invalid_ballots_01`.`region`) and (`raw`.`district_id` = `invalid_ballots_01`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_01`.`precinct_id`)))) left join `2013 election pres - invalid ballots 1-3` `invalid_ballots_13` on(((`raw`.`region` = `invalid_ballots_13`.`region`) and (`raw`.`district_id` = `invalid_ballots_13`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_13`.`precinct_id`)))) left join `2013 election pres - invalid ballots 3-5` `invalid_ballots_35` on(((`raw`.`region` = `invalid_ballots_35`.`region`) and (`raw`.`district_id` = `invalid_ballots_35`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_35`.`precinct_id`)))) left join `2013 election pres - invalid ballots >5` `invalid_ballots_>5` on(((`raw`.`region` = `invalid_ballots_>5`.`region`) and (`raw`.`district_id` = `invalid_ballots_>5`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_>5`.`precinct_id`)))) group by `raw`.`region`;
  
  
  
  
  drop view if exists `2013 election pres - tbilisi district`;
  create view `2013 election pres - tbilisi district` as
  select `raw`.`region` AS `region`,
  `raw`.`district_id` AS `district_id`,
  `raw`.`district_name` AS `district_Name`,
  sum(`raw`.`num_possible_voters`) AS `possible voters`,
  sum(`raw`.`num_votes`) AS `total ballots cast`,
  sum(`raw`.`num_valid_votes`) AS `total valid ballots cast`,
  ifnull(sum(`invalid_ballots_01`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 0-1%`,
  ifnull(sum(`invalid_ballots_13`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 1-3%`,
  ifnull(sum(`invalid_ballots_35`.`num_invalid_ballots`),
  0) AS `num invalid ballots from 3-5%`,
  ifnull(sum(`invalid_ballots_>5`.`num_invalid_ballots`),
  0) AS `num invalid ballots >5%`,
  (100 * (sum(`raw`.`num_valid_votes`) / sum(`raw`.`num_possible_voters`))) AS `percent voters voting`,
  sum(`raw`.`logic_check_fail`) AS `num precincts logic fail`,
  (100 * (sum(`raw`.`logic_check_fail`) / count(0))) AS `percent precincts logic fail`,
  (sum(`raw`.`logic_check_difference`) / sum(`raw`.`logic_check_fail`)) AS `avg precinct logic fail difference`,
  sum(`raw`.`more_ballots_than_votes_flag`) AS `num precincts more ballots than votes`,
  (100 * (sum(`raw`.`more_ballots_than_votes_flag`) / count(0))) AS `percent precincts more ballots than votes`,
  (sum(`raw`.`more_ballots_than_votes`) / sum(`raw`.`more_ballots_than_votes_flag`)) AS `avg precinct difference more ballots than votes`,
  sum(`raw`.`more_votes_than_ballots_flag`) AS `num precincts more votes than ballots`,
  (100 * (sum(`raw`.`more_votes_than_ballots_flag`) / count(0))) AS `percent precincts more votes than ballots`,
  (sum(`raw`.`more_votes_than_ballots`) / sum(`raw`.`more_votes_than_ballots_flag`)) AS `avg precinct difference more votes than ballots`,
  sum(`raw`.`num_at_12`) AS `votes 8-12`,
  sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) AS `votes 12-17`,
  sum((`raw`.`num_votes` - `raw`.`num_at_17`)) AS `votes 17-20`,
  (sum(`raw`.`num_at_12`) / count(0)) AS `avg votes/precinct 8-12`,
  (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / count(0)) AS `avg votes/precinct 12-17`,
  (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / count(0)) AS `avg votes/precinct 17-20`,
  (sum(`raw`.`num_at_12`) / 240) AS `vpm 8-12`,
  (sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) AS `vpm 12-17`,
  (sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 300) AS `vpm 17-20`,
  ((sum(`raw`.`num_at_12`) / 240) / count(0)) AS `avg vpm/precinct 8-12`,
  ((sum((`raw`.`num_at_17` - `raw`.`num_at_12`)) / 180) / count(0)) AS `avg vpm/precinct 12-17`,
  ((sum((`raw`.`num_votes` - `raw`.`num_at_17`)) / 200) / count(0)) AS `avg vpm/precinct 17-20`,
  ifnull(sum(`vpm1`.`vpm > 2`),
  0) AS `num precincts vpm 8-12 > 2`,
  ifnull(sum(`vpm2`.`vpm > 2`),
  0) AS `num precincts vpm 12-17 > 2`,
  ifnull(sum(`vpm3`.`vpm > 2`),
  0) AS `num precincts vpm 17-20 > 2`,
  ((ifnull(sum(`vpm1`.`vpm > 2`),
  0) + ifnull(sum(`vpm2`.`vpm > 2`),
  0)) + ifnull(sum(`vpm3`.`vpm > 2`),
  0)) AS `num precincts vpm > 2`,
  `precinct_count`.`num_precincts` AS `num_precincts_possible`,
  count(`raw`.`precinct_id`) AS `num_precincts_reported_number`,
  ((100 * count(`raw`.`precinct_id`)) / `precinct_count`.`num_precincts`) AS `num_precincts_reported_percent`,
  sum(`raw`.`1 - Tamaz Bibiluri`) AS `1 - Tamaz Bibiluri count`,
  (100 * (sum(`raw`.`1 - Tamaz Bibiluri`) / sum(`raw`.`num_valid_votes`))) AS `1 - Tamaz Bibiluri`,
  sum(`raw`.`2 - Giorgi Liluashvili`) AS `2 - Giorgi Liluashvili count`,
  (100 * (sum(`raw`.`2 - Giorgi Liluashvili`) / sum(`raw`.`num_valid_votes`))) AS `2 - Giorgi Liluashvili`,
  sum(`raw`.`3 - Sergo Javakhidze`) AS `3 - Sergo Javakhidze count`,
  (100 * (sum(`raw`.`3 - Sergo Javakhidze`) / sum(`raw`.`num_valid_votes`))) AS `3 - Sergo Javakhidze`,
  sum(`raw`.`4 - Koba Davitashvili`) AS `4 - Koba Davitashvili count`,
  (100 * (sum(`raw`.`4 - Koba Davitashvili`) / sum(`raw`.`num_valid_votes`))) AS `4 - Koba Davitashvili`,
  sum(`raw`.`5 - Davit Bakradze`) AS `5 - Davit Bakradze count`,
  (100 * (sum(`raw`.`5 - Davit Bakradze`) / sum(`raw`.`num_valid_votes`))) AS `5 - Davit Bakradze`,
  sum(`raw`.`6 - Akaki Asatiani`) AS `6 - Akaki Asatiani count`,
  (100 * (sum(`raw`.`6 - Akaki Asatiani`) / sum(`raw`.`num_valid_votes`))) AS `6 - Akaki Asatiani`,
  sum(`raw`.`7 - Nino Chanishvili`) AS `7 - Nino Chanishvili count`,
  (100 * (sum(`raw`.`7 - Nino Chanishvili`) / sum(`raw`.`num_valid_votes`))) AS `7 - Nino Chanishvili`,
  sum(`raw`.`8 - Teimuraz Bobokhidze`) AS `8 - Teimuraz Bobokhidze count`,
  (100 * (sum(`raw`.`8 - Teimuraz Bobokhidze`) / sum(`raw`.`num_valid_votes`))) AS `8 - Teimuraz Bobokhidze`,
  sum(`raw`.`9 - Shalva Natelashvili`) AS `9 - Shalva Natelashvili count`,
  (100 * (sum(`raw`.`9 - Shalva Natelashvili`) / sum(`raw`.`num_valid_votes`))) AS `9 - Shalva Natelashvili`,
  sum(`raw`.`10 - Giorgi Targamadze`) AS `10 - Giorgi Targamadze count`,
  (100 * (sum(`raw`.`10 - Giorgi Targamadze`) / sum(`raw`.`num_valid_votes`))) AS `10 - Giorgi Targamadze`,
  sum(`raw`.`11 - Levan Chachua`) AS `11 - Levan Chachua count`,
  (100 * (sum(`raw`.`11 - Levan Chachua`) / sum(`raw`.`num_valid_votes`))) AS `11 - Levan Chachua`,
  sum(`raw`.`12 - Nestan Kirtadze`) AS `12 - Nestan Kirtadze count`,
  (100 * (sum(`raw`.`12 - Nestan Kirtadze`) / sum(`raw`.`num_valid_votes`))) AS `12 - Nestan Kirtadze`,
  sum(`raw`.`13 - Giorgi Chikhladze`) AS `13 - Giorgi Chikhladze count`,
  (100 * (sum(`raw`.`13 - Giorgi Chikhladze`) / sum(`raw`.`num_valid_votes`))) AS `13 - Giorgi Chikhladze`,
  sum(`raw`.`14 - Nino Burjanadze`) AS `14 - Nino Burjanadze count`,
  (100 * (sum(`raw`.`14 - Nino Burjanadze`) / sum(`raw`.`num_valid_votes`))) AS `14 - Nino Burjanadze`,
  sum(`raw`.`15 - Zurab Kharatishvili`) AS `15 - Zurab Kharatishvili count`,
  (100 * (sum(`raw`.`15 - Zurab Kharatishvili`) / sum(`raw`.`num_valid_votes`))) AS `15 - Zurab Kharatishvili`,
  sum(`raw`.`16 - Mikheil Saluashvili`) AS `16 - Mikheil Saluashvili count`,
  (100 * (sum(`raw`.`16 - Mikheil Saluashvili`) / sum(`raw`.`num_valid_votes`))) AS `16 - Mikheil Saluashvili`,
  sum(`raw`.`17 - Kartlos Gharibashvili`) AS `17 - Kartlos Gharibashvili count`,
  (100 * (sum(`raw`.`17 - Kartlos Gharibashvili`) / sum(`raw`.`num_valid_votes`))) AS `17 - Kartlos Gharibashvili`,
  sum(`raw`.`18 - Mamuka Chokhonelidze`) AS `18 - Mamuka Chokhonelidze count`,
  (100 * (sum(`raw`.`18 - Mamuka Chokhonelidze`) / sum(`raw`.`num_valid_votes`))) AS `18 - Mamuka Chokhonelidze`,
  sum(`raw`.`19 - Avtandil Margiani`) AS `19 - Avtandil Margiani count`,
  (100 * (sum(`raw`.`19 - Avtandil Margiani`) / sum(`raw`.`num_valid_votes`))) AS `19 - Avtandil Margiani`,
  sum(`raw`.`20 - Nugzar Avaliani`) AS `20 - Nugzar Avaliani count`,
  (100 * (sum(`raw`.`20 - Nugzar Avaliani`) / sum(`raw`.`num_valid_votes`))) AS `20 - Nugzar Avaliani`,
  sum(`raw`.`21 - Mamuka Melikishvili`) AS `21 - Mamuka Melikishvili count`,
  (100 * (sum(`raw`.`21 - Mamuka Melikishvili`) / sum(`raw`.`num_valid_votes`))) AS `21 - Mamuka Melikishvili`,
  sum(`raw`.`22 - Teimuraz Mzhavia`) AS `22 - Teimuraz Mzhavia count`,
  (100 * (sum(`raw`.`22 - Teimuraz Mzhavia`) / sum(`raw`.`num_valid_votes`))) AS `22 - Teimuraz Mzhavia`,
  sum(`raw`.`41 - Giorgi Margvelashvili`) AS `41 - Giorgi Margvelashvili count`,
  (100 * (sum(`raw`.`41 - Giorgi Margvelashvili`) / sum(`raw`.`num_valid_votes`))) AS `41 - Giorgi Margvelashvili` 
  from ((((((((`2013 election pres - raw` `raw` join `2012 election parl - precinct count by district` `precinct_count` on((`raw`.`district_id` = `precinct_count`.`district_id`))) left join `2013 election pres - vpm 8-12>2` `vpm1` on(((`raw`.`region` = `vpm1`.`region`) and (`raw`.`district_id` = `vpm1`.`district_id`) and (`raw`.`precinct_id` = `vpm1`.`precinct_id`)))) left join `2013 election pres - vpm 12-17>2` `vpm2` on(((`raw`.`region` = `vpm2`.`region`) and (`raw`.`district_id` = `vpm2`.`district_id`) and (`raw`.`precinct_id` = `vpm2`.`precinct_id`)))) left join `2013 election pres - vpm 17-20>2` `vpm3` on(((`raw`.`region` = convert(`vpm3`.`region` using utf8)) and (`raw`.`district_id` = `vpm3`.`district_id`) and (`raw`.`precinct_id` = `vpm3`.`precinct_id`)))) left join `2013 election pres - invalid ballots 0-1` `invalid_ballots_01` on(((`raw`.`region` = `invalid_ballots_01`.`region`) and (`raw`.`district_id` = `invalid_ballots_01`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_01`.`precinct_id`)))) left join `2013 election pres - invalid ballots 1-3` `invalid_ballots_13` on(((`raw`.`region` = `invalid_ballots_13`.`region`) and (`raw`.`district_id` = `invalid_ballots_13`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_13`.`precinct_id`)))) left join `2013 election pres - invalid ballots 3-5` `invalid_ballots_35` on(((`raw`.`region` = `invalid_ballots_35`.`region`) and (`raw`.`district_id` = `invalid_ballots_35`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_35`.`precinct_id`)))) left join `2013 election pres - invalid ballots >5` `invalid_ballots_>5` on(((`raw`.`region` = `invalid_ballots_>5`.`region`) and (`raw`.`district_id` = `invalid_ballots_>5`.`district_id`) and (`raw`.`precinct_id` = `invalid_ballots_>5`.`precinct_id`)))) where (`raw`.`district_id` between 1 and 10) group by `raw`.`region`,
  `raw`.`district_name`,
  `raw`.`district_id`;
  
  
  
  drop view if exists `2013 election pres - tbilisi precincts`;
  create view `2013 election pres - tbilisi precincts` as
  select `raw`.`region` AS `region`,
  `raw`.`district_id` AS `district_id`,
  `raw`.`district_name` AS `district_Name`,
  `raw`.`precinct_id` AS `precinct_id`,
  concat(cast(`raw`.`district_id` as char charset utf8),
  '-',
  cast(`raw`.`precinct_id` as char charset utf8)) AS `precinct_name`,
  `raw`.`num_possible_voters` AS `possible voters`,
  `raw`.`num_votes` AS `total ballots cast`,
  `raw`.`num_valid_votes` AS `total valid ballots cast`,
  (100 * (`raw`.`num_invalid_votes` / `raw`.`num_votes`)) AS `percent invalid ballots`,
  (100 * (`raw`.`num_valid_votes` / `raw`.`num_possible_voters`)) AS `percent voters voting`,
  `raw`.`logic_check_fail` AS `logic_check_fail`,
  `raw`.`logic_check_difference` AS `logic_check_difference`,
  `raw`.`more_ballots_than_votes_flag` as `more_ballots_than_votes_flag`,
  `raw`.`more_ballots_than_votes` as `more_ballots_than_votes`,
  `raw`.`more_votes_than_ballots_flag` as `more_votes_than_ballots_flag`,
  `raw`.`more_votes_than_ballots` as `more_votes_than_ballots`,
  `raw`.`num_at_12` AS `votes 8-12`,
  (`raw`.`num_at_17` - `raw`.`num_at_12`) AS `votes 12-17`,
  (`raw`.`num_votes` - `raw`.`num_at_17`) AS `votes 17-20`,
  (`raw`.`num_at_12` / 240) AS `vpm 8-12`,
  ((`raw`.`num_at_17` - `raw`.`num_at_12`) / 300) AS `vpm 12-17`,
  ((`raw`.`num_votes` - `raw`.`num_at_17`) / 180) AS `vpm 17-20`,
  `raw`.`1 - Tamaz Bibiluri` AS `1 - Tamaz Bibiluri count`,
  (100 * (`raw`.`1 - Tamaz Bibiluri` / `raw`.`num_valid_votes`)) AS `1 - Tamaz Bibiluri`,
  `raw`.`2 - Giorgi Liluashvili` AS `2 - Giorgi Liluashvili count`,
  (100 * (`raw`.`2 - Giorgi Liluashvili` / `raw`.`num_valid_votes`)) AS `2 - Giorgi Liluashvili`,
  `raw`.`3 - Sergo Javakhidze` AS `3 - Sergo Javakhidze count`,
  (100 * (`raw`.`3 - Sergo Javakhidze` / `raw`.`num_valid_votes`)) AS `3 - Sergo Javakhidze`,
  `raw`.`4 - Koba Davitashvili` AS `4 - Koba Davitashvili count`,
  (100 * (`raw`.`4 - Koba Davitashvili` / `raw`.`num_valid_votes`)) AS `4 - Koba Davitashvili`,
  `raw`.`5 - Davit Bakradze` AS `5 - Davit Bakradze count`,
  (100 * (`raw`.`5 - Davit Bakradze` / `raw`.`num_valid_votes`)) AS `5 - Davit Bakradze`,
  `raw`.`6 - Akaki Asatiani` AS `6 - Akaki Asatiani count`,
  (100 * (`raw`.`6 - Akaki Asatiani` / `raw`.`num_valid_votes`)) AS `6 - Akaki Asatiani`,
  `raw`.`7 - Nino Chanishvili` AS `7 - Nino Chanishvili count`,
  (100 * (`raw`.`7 - Nino Chanishvili` / `raw`.`num_valid_votes`)) AS `7 - Nino Chanishvili`,
  `raw`.`8 - Teimuraz Bobokhidze` AS `8 - Teimuraz Bobokhidze count`,
  (100 * (`raw`.`8 - Teimuraz Bobokhidze` / `raw`.`num_valid_votes`)) AS `8 - Teimuraz Bobokhidze`,
  `raw`.`9 - Shalva Natelashvili` AS `9 - Shalva Natelashvili count`,
  (100 * (`raw`.`9 - Shalva Natelashvili` / `raw`.`num_valid_votes`)) AS `9 - Shalva Natelashvili`,
  `raw`.`10 - Giorgi Targamadze` AS `10 - Giorgi Targamadze count`,
  (100 * (`raw`.`10 - Giorgi Targamadze` / `raw`.`num_valid_votes`)) AS `10 - Giorgi Targamadze`,
  `raw`.`11 - Levan Chachua` AS `11 - Levan Chachua count`,
  (100 * (`raw`.`11 - Levan Chachua` / `raw`.`num_valid_votes`)) AS `11 - Levan Chachua`,
  `raw`.`12 - Nestan Kirtadze` AS `12 - Nestan Kirtadze count`,
  (100 * (`raw`.`12 - Nestan Kirtadze` / `raw`.`num_valid_votes`)) AS `12 - Nestan Kirtadze`,
  `raw`.`13 - Giorgi Chikhladze` AS `13 - Giorgi Chikhladze count`,
  (100 * (`raw`.`13 - Giorgi Chikhladze` / `raw`.`num_valid_votes`)) AS `13 - Giorgi Chikhladze`,
  `raw`.`14 - Nino Burjanadze` AS `14 - Nino Burjanadze count`,
  (100 * (`raw`.`14 - Nino Burjanadze` / `raw`.`num_valid_votes`)) AS `14 - Nino Burjanadze`,
  `raw`.`15 - Zurab Kharatishvili` AS `15 - Zurab Kharatishvili count`,
  (100 * (`raw`.`15 - Zurab Kharatishvili` / `raw`.`num_valid_votes`)) AS `15 - Zurab Kharatishvili`,
  `raw`.`16 - Mikheil Saluashvili` AS `16 - Mikheil Saluashvili count`,
  (100 * (`raw`.`16 - Mikheil Saluashvili` / `raw`.`num_valid_votes`)) AS `16 - Mikheil Saluashvili`,
  `raw`.`17 - Kartlos Gharibashvili` AS `17 - Kartlos Gharibashvili count`,
  (100 * (`raw`.`17 - Kartlos Gharibashvili` / `raw`.`num_valid_votes`)) AS `17 - Kartlos Gharibashvili`,
  `raw`.`18 - Mamuka Chokhonelidze` AS `18 - Mamuka Chokhonelidze count`,
  (100 * (`raw`.`18 - Mamuka Chokhonelidze` / `raw`.`num_valid_votes`)) AS `18 - Mamuka Chokhonelidze`,
  `raw`.`19 - Avtandil Margiani` AS `19 - Avtandil Margiani count`,
  (100 * (`raw`.`19 - Avtandil Margiani` / `raw`.`num_valid_votes`)) AS `19 - Avtandil Margiani`,
  `raw`.`20 - Nugzar Avaliani` AS `20 - Nugzar Avaliani count`,
  (100 * (`raw`.`20 - Nugzar Avaliani` / `raw`.`num_valid_votes`)) AS `20 - Nugzar Avaliani`,
  `raw`.`21 - Mamuka Melikishvili` AS `21 - Mamuka Melikishvili count`,
  (100 * (`raw`.`21 - Mamuka Melikishvili` / `raw`.`num_valid_votes`)) AS `21 - Mamuka Melikishvili`,
  `raw`.`22 - Teimuraz Mzhavia` AS `22 - Teimuraz Mzhavia count`,
  (100 * (`raw`.`22 - Teimuraz Mzhavia` / `raw`.`num_valid_votes`)) AS `22 - Teimuraz Mzhavia`,
  `raw`.`41 - Giorgi Margvelashvili` AS `41 - Giorgi Margvelashvili count`,
  (100 * (`raw`.`41 - Giorgi Margvelashvili` / `raw`.`num_valid_votes`)) AS `41 - Giorgi Margvelashvili` 
  from `2013 election pres - raw` `raw` where (`raw`.`district_id` between 1 and 10);
  
  
  
  
  
  drop view if exists `2013 election pres - csv`;
  create view `2013 election pres - csv` as
  (select 'Country' AS `shape`,
  'Georgia' AS `common_id`,
  'Georgia' AS `common_name`,
  `2013 election pres - country`.`total valid ballots cast` AS `Total Voter Turnout (#)`,
  `2013 election pres - country`.`percent voters voting` AS `Total Voter Turnout (%)`,
  `2013 election pres - country`.`num invalid ballots from 0-1%` AS `Number of Precincts with Invalid Ballots from 0-1%`,
  `2013 election pres - country`.`num invalid ballots from 1-3%` AS `Number of Precincts with Invalid Ballots from 1-3%`,
  `2013 election pres - country`.`num invalid ballots from 3-5%` AS `Number of Precincts with Invalid Ballots from 3-5%`,
  `2013 election pres - country`.`num invalid ballots >5%` AS `Number of Precincts with Invalid Ballots > 5%`,
  NULL AS `Invalid Ballots (%)`,
  `2013 election pres - country`.`num precincts logic fail` AS `Precincts with Validation Errors (#)`,
  `2013 election pres - country`.`percent precincts logic fail` AS `Precincts with Validation Errors (%)`,
  `2013 election pres - country`.`avg precinct logic fail difference` AS `Average Number of Validation Errors`, 
  NULL AS `Number of Validation Errors`,
  `2013 election pres - country`.`num precincts more ballots than votes` AS `Precincts with More Ballots Than Votes (#)`,
  `2013 election pres - country`.`percent precincts more ballots than votes` AS `Precincts with More Ballots Than Votes (%)`,
  `2013 election pres - country`.`avg precinct difference more ballots than votes` AS `More Ballots Than Votes (Average)`, 
  NULL AS `More Ballots Than Votes (#)`,
  `2013 election pres - country`.`num precincts more votes than ballots` AS `Precincts with More Votes than Ballots (#)`,
  `2013 election pres - country`.`percent precincts more votes than ballots` AS `Precincts with More Votes than Ballots (%)`,
  `2013 election pres - country`.`avg precinct difference more votes than ballots` AS `More Votes than Ballots (Average)`, 
  NULL AS `More Votes than Ballots (#)`,
  NULL AS `Average votes per minute (08:00-12:00)`,
  NULL AS `Average votes per minute (12:00-17:00)`,
  NULL AS `Average votes per minute (17:00-20:00)`,
  `2013 election pres - country`.`num precincts vpm 8-12 > 2` AS `Number of Precincts with votes per minute > 2 (08:00-12:00)`,
  `2013 election pres - country`.`num precincts vpm 12-17 > 2` AS `Number of Precincts with votes per minute > 2 (12:00-17:00)`,
  `2013 election pres - country`.`num precincts vpm 17-20 > 2` AS `Number of Precincts with votes per minute > 2 (17:00-20:00)`,
  `2013 election pres - country`.`num precincts vpm > 2` AS `Number of Precincts with votes per minute > 2`,
  `2013 election pres - country`.`num_precincts_reported_number` AS `Precincts Reported (#)`,
  `2013 election pres - country`.`num_precincts_reported_percent` AS `Precincts Reported (%)`,
  `2013 election pres - country`.`1 - Tamaz Bibiluri` AS `Tamaz Bibiluri`,
  `2013 election pres - country`.`2 - Giorgi Liluashvili` AS `Giorgi Liluashvili`,
  `2013 election pres - country`.`3 - Sergo Javakhidze` AS `Sergo Javakhidze`,
  `2013 election pres - country`.`4 - Koba Davitashvili` AS `Koba Davitashvili`,
  `2013 election pres - country`.`5 - Davit Bakradze` AS `Davit Bakradze`,
  `2013 election pres - country`.`6 - Akaki Asatiani` AS `Akaki Asatiani`,
  `2013 election pres - country`.`7 - Nino Chanishvili` AS `Nino Chanishvili`,
  `2013 election pres - country`.`8 - Teimuraz Bobokhidze` AS `Teimuraz Bobokhidze`,
  `2013 election pres - country`.`9 - Shalva Natelashvili` AS `Shalva Natelashvili`,
  `2013 election pres - country`.`10 - Giorgi Targamadze` AS `Giorgi Targamadze`,
  `2013 election pres - country`.`11 - Levan Chachua` AS `Levan Chachua`,
  `2013 election pres - country`.`12 - Nestan Kirtadze` AS `Nestan Kirtadze`,
  `2013 election pres - country`.`13 - Giorgi Chikhladze` AS `Giorgi Chikhladze`,
  `2013 election pres - country`.`14 - Nino Burjanadze` AS `Nino Burjanadze`,
  `2013 election pres - country`.`15 - Zurab Kharatishvili` AS `Zurab Kharatishvili`,
  `2013 election pres - country`.`16 - Mikheil Saluashvili` AS `Mikheil Saluashvili`,
  `2013 election pres - country`.`17 - Kartlos Gharibashvili` AS `Kartlos Gharibashvili`,
  `2013 election pres - country`.`18 - Mamuka Chokhonelidze` AS `Mamuka Chokhonelidze`,
  `2013 election pres - country`.`19 - Avtandil Margiani` AS `Avtandil Margiani`,
  `2013 election pres - country`.`20 - Nugzar Avaliani` AS `Nugzar Avaliani`,
  `2013 election pres - country`.`21 - Mamuka Melikishvili` AS `Mamuka Melikishvili`,
  `2013 election pres - country`.`22 - Teimuraz Mzhavia` AS `Teimuraz Mzhavia`,
  `2013 election pres - country`.`41 - Giorgi Margvelashvili` AS `Giorgi Margvelashvili`
  from `2013 election pres - country`)
  union
  (select 'Region' AS `shape`,
  `2013 election pres - region`.`region` AS `common_id`,
  `2013 election pres - region`.`region` AS `common_name`,
  `2013 election pres - region`.`total valid ballots cast` AS `Total Voter Turnout (#)`,
  `2013 election pres - region`.`percent voters voting` AS `Total Voter Turnout (%)`,
  `2013 election pres - region`.`num invalid ballots from 0-1%` AS `Number of Precincts with Invalid Ballots from 0-1%`,
  `2013 election pres - region`.`num invalid ballots from 1-3%` AS `Number of Precincts with Invalid Ballots from 1-3%`,
  `2013 election pres - region`.`num invalid ballots from 3-5%` AS `Number of Precincts with Invalid Ballots from 3-5%`,
  `2013 election pres - region`.`num invalid ballots >5%` AS `Number of Precincts with Invalid Ballots > 5%`,
  NULL AS `Invalid Ballots (%)`,
  `2013 election pres - region`.`num precincts logic fail` AS `Precincts with Validation Errors (#)`,
  `2013 election pres - region`.`percent precincts logic fail` AS `Precincts with Validation Errors (%)`,
  `2013 election pres - region`.`avg precinct logic fail difference` AS `Average Number of Validation Errors`, 
  NULL AS `Number of Validation Errors`,
  `2013 election pres - region`.`num precincts more ballots than votes` AS `Precincts with More Ballots Than Votes (#)`,
  `2013 election pres - region`.`percent precincts more ballots than votes` AS `Precincts with More Ballots Than Votes (%)`,
  `2013 election pres - region`.`avg precinct difference more ballots than votes` AS `More Ballots Than Votes (Average)`, 
  NULL AS `More Ballots Than Votes (#)`,
  `2013 election pres - region`.`num precincts more votes than ballots` AS `Precincts with More Votes than Ballots (#)`,
  `2013 election pres - region`.`percent precincts more votes than ballots` AS `Precincts with More Votes than Ballots (%)`,
  `2013 election pres - region`.`avg precinct difference more votes than ballots` AS `More Votes than Ballots (Average)`, 
  NULL AS `More Votes than Ballots (#)`,
  NULL AS `Average votes per minute (08:00-12:00)`,
  NULL AS `Average votes per minute (12:00-17:00)`,
  NULL AS `Average votes per minute (17:00-20:00)`,
  `2013 election pres - region`.`num precincts vpm 8-12 > 2` AS `Number of Precincts with votes per minute > 2 (08:00-12:00)`,
  `2013 election pres - region`.`num precincts vpm 12-17 > 2` AS `Number of Precincts with votes per minute > 2 (12:00-17:00)`,
  `2013 election pres - region`.`num precincts vpm 17-20 > 2` AS `Number of Precincts with votes per minute > 2 (17:00-20:00)`,
  `2013 election pres - region`.`num precincts vpm > 2` AS `Number of Precincts with votes per minute > 2`,
  `2013 election pres - region`.`num_precincts_reported_number` AS `Precincts Reported (#)`,
  `2013 election pres - region`.`num_precincts_reported_percent` AS `Precincts Reported (%)`,
  `2013 election pres - region`.`1 - Tamaz Bibiluri` AS `Tamaz Bibiluri`,
  `2013 election pres - region`.`2 - Giorgi Liluashvili` AS `Giorgi Liluashvili`,
  `2013 election pres - region`.`3 - Sergo Javakhidze` AS `Sergo Javakhidze`,
  `2013 election pres - region`.`4 - Koba Davitashvili` AS `Koba Davitashvili`,
  `2013 election pres - region`.`5 - Davit Bakradze` AS `Davit Bakradze`,
  `2013 election pres - region`.`6 - Akaki Asatiani` AS `Akaki Asatiani`,
  `2013 election pres - region`.`7 - Nino Chanishvili` AS `Nino Chanishvili`,
  `2013 election pres - region`.`8 - Teimuraz Bobokhidze` AS `Teimuraz Bobokhidze`,
  `2013 election pres - region`.`9 - Shalva Natelashvili` AS `Shalva Natelashvili`,
  `2013 election pres - region`.`10 - Giorgi Targamadze` AS `Giorgi Targamadze`,
  `2013 election pres - region`.`11 - Levan Chachua` AS `Levan Chachua`,
  `2013 election pres - region`.`12 - Nestan Kirtadze` AS `Nestan Kirtadze`,
  `2013 election pres - region`.`13 - Giorgi Chikhladze` AS `Giorgi Chikhladze`,
  `2013 election pres - region`.`14 - Nino Burjanadze` AS `Nino Burjanadze`,
  `2013 election pres - region`.`15 - Zurab Kharatishvili` AS `Zurab Kharatishvili`,
  `2013 election pres - region`.`16 - Mikheil Saluashvili` AS `Mikheil Saluashvili`,
  `2013 election pres - region`.`17 - Kartlos Gharibashvili` AS `Kartlos Gharibashvili`,
  `2013 election pres - region`.`18 - Mamuka Chokhonelidze` AS `Mamuka Chokhonelidze`,
  `2013 election pres - region`.`19 - Avtandil Margiani` AS `Avtandil Margiani`,
  `2013 election pres - region`.`20 - Nugzar Avaliani` AS `Nugzar Avaliani`,
  `2013 election pres - region`.`21 - Mamuka Melikishvili` AS `Mamuka Melikishvili`,
  `2013 election pres - region`.`22 - Teimuraz Mzhavia` AS `Teimuraz Mzhavia`,
  `2013 election pres - region`.`41 - Giorgi Margvelashvili` AS `Giorgi Margvelashvili`
  from `2013 election pres - region`)
  union
  (select 'District' AS `shape`,
  `2013 election pres - districts`.`district_id` AS `common_id`,
  `2013 election pres - districts`.`district_Name` AS `common_name`,
  `2013 election pres - districts`.`total valid ballots cast` AS `Total Voter Turnout (#)`,
  `2013 election pres - districts`.`percent voters voting` AS `Total Voter Turnout (%)`,
  `2013 election pres - districts`.`num invalid ballots from 0-1%` AS `Number of Precincts with Invalid Ballots from 0-1%`,
  `2013 election pres - districts`.`num invalid ballots from 1-3%` AS `Number of Precincts with Invalid Ballots from 1-3%`,
  `2013 election pres - districts`.`num invalid ballots from 3-5%` AS `Number of Precincts with Invalid Ballots from 3-5%`,
  `2013 election pres - districts`.`num invalid ballots >5%` AS `Number of Precincts with Invalid Ballots > 5%`,
  NULL AS `Invalid Ballots (%)`,
  `2013 election pres - districts`.`num precincts logic fail` AS `Precincts with Validation Errors (#)`,
  `2013 election pres - districts`.`percent precincts logic fail` AS `Precincts with Validation Errors (%)`,
  `2013 election pres - districts`.`avg precinct logic fail difference` AS `Average Number of Validation Errors`, 
  NULL AS `Number of Validation Errors`,
  `2013 election pres - districts`.`num precincts more ballots than votes` AS `Precincts with More Ballots Than Votes (#)`,
  `2013 election pres - districts`.`percent precincts more ballots than votes` AS `Precincts with More Ballots Than Votes (%)`,
  `2013 election pres - districts`.`avg precinct difference more ballots than votes` AS `More Ballots Than Votes (Average)`, 
  NULL AS `More Ballots Than Votes (#)`,
  `2013 election pres - districts`.`num precincts more votes than ballots` AS `Precincts with More Votes than Ballots (#)`,
  `2013 election pres - districts`.`percent precincts more votes than ballots` AS `Precincts with More Votes than Ballots (%)`,
  `2013 election pres - districts`.`avg precinct difference more votes than ballots` AS `More Votes than Ballots (Average)`, 
  NULL AS `More Votes than Ballots (#)`,
  NULL AS `Average votes per minute (08:00-12:00)`,
  NULL AS `Average votes per minute (12:00-17:00)`,
  NULL AS `Average votes per minute (17:00-20:00)`,
  `2013 election pres - districts`.`num precincts vpm 8-12 > 2` AS `Number of Precincts with votes per minute > 2 (08:00-12:00)`,
  `2013 election pres - districts`.`num precincts vpm 12-17 > 2` AS `Number of Precincts with votes per minute > 2 (12:00-17:00)`,
  `2013 election pres - districts`.`num precincts vpm 17-20 > 2` AS `Number of Precincts with votes per minute > 2 (17:00-20:00)`,
  `2013 election pres - districts`.`num precincts vpm > 2` AS `Number of Precincts with votes per minute > 2`,
  `2013 election pres - districts`.`num_precincts_reported_number` AS `Precincts Reported (#)`,
  `2013 election pres - districts`.`num_precincts_reported_percent` AS `Precincts Reported (%)`,
  `2013 election pres - districts`.`1 - Tamaz Bibiluri` AS `1 - Tamaz Bibiluri`,
  `2013 election pres - districts`.`2 - Giorgi Liluashvili` AS `Giorgi Liluashvili`,
  `2013 election pres - districts`.`3 - Sergo Javakhidze` AS `Sergo Javakhidze`,
  `2013 election pres - districts`.`4 - Koba Davitashvili` AS `Koba Davitashvili`,
  `2013 election pres - districts`.`5 - Davit Bakradze` AS `Davit Bakradze`,
  `2013 election pres - districts`.`6 - Akaki Asatiani` AS `Akaki Asatiani`,
  `2013 election pres - districts`.`7 - Nino Chanishvili` AS `Nino Chanishvili`,
  `2013 election pres - districts`.`8 - Teimuraz Bobokhidze` AS `Teimuraz Bobokhidze`,
  `2013 election pres - districts`.`9 - Shalva Natelashvili` AS `Shalva Natelashvili`,
  `2013 election pres - districts`.`10 - Giorgi Targamadze` AS `Giorgi Targamadze`,
  `2013 election pres - districts`.`11 - Levan Chachua` AS `Levan Chachua`,
  `2013 election pres - districts`.`12 - Nestan Kirtadze` AS `Nestan Kirtadze`,
  `2013 election pres - districts`.`13 - Giorgi Chikhladze` AS `Giorgi Chikhladze`,
  `2013 election pres - districts`.`14 - Nino Burjanadze` AS `Nino Burjanadze`,
  `2013 election pres - districts`.`15 - Zurab Kharatishvili` AS `Zurab Kharatishvili`,
  `2013 election pres - districts`.`16 - Mikheil Saluashvili` AS `Mikheil Saluashvili`,
  `2013 election pres - districts`.`17 - Kartlos Gharibashvili` AS `Kartlos Gharibashvili`,
  `2013 election pres - districts`.`18 - Mamuka Chokhonelidze` AS `Mamuka Chokhonelidze`,
  `2013 election pres - districts`.`19 - Avtandil Margiani` AS `Avtandil Margiani`,
  `2013 election pres - districts`.`20 - Nugzar Avaliani` AS `Nugzar Avaliani`,
  `2013 election pres - districts`.`21 - Mamuka Melikishvili` AS `Mamuka Melikishvili`,
  `2013 election pres - districts`.`22 - Teimuraz Mzhavia` AS `Teimuraz Mzhavia`,
  `2013 election pres - districts`.`41 - Giorgi Margvelashvili` AS `Giorgi Margvelashvili`
  from `2013 election pres - districts`)
  union
  (select 'Precinct' AS `shape`,
  `2013 election pres - precincts`.`precinct_id` AS `common_id`,
  `2013 election pres - precincts`.`precinct_name` AS `common_name`,
  `2013 election pres - precincts`.`total valid ballots cast` AS `Total Voter Turnout (#)`,
  `2013 election pres - precincts`.`percent voters voting` AS `Total Voter Turnout (%)`,
  NULL AS `Number of Precincts with Invalid Ballots from 0-1%`,
  NULL AS `Number of Precincts with Invalid Ballots from 1-3%`,
  NULL AS `Number of Precincts with Invalid Ballots from 3-5%`,
  NULL AS `Number of Precincts with Invalid Ballots > 5%`,
  `2013 election pres - precincts`.`percent invalid ballots` AS `Invalid Ballots (%)`,
  NULL AS `Precincts with Validation Errors (#)`,
  NULL AS `Precincts with Validation Errors (%)`,
  NULL AS `Average Number of Validation Errors`, 
  `2013 election pres - precincts`.`logic_check_difference` AS `Number of Validation Errors`,
  null AS `Precincts with More Ballots Than Votes (#)`,
  null AS `Precincts with More Ballots Than Votes (%)`,
  null AS `More Ballots Than Votes (Average)`, 
  `2013 election pres - precincts`.`more_ballots_than_votes` AS `More Ballots Than Votes (#)`,
  null AS `Precincts with More Votes than Ballots (#)`,
  null AS `Precincts with More Votes than Ballots (%)`,
  null AS `More Votes than Ballots (Average)`, 
  `2013 election pres - precincts`.`more_votes_than_ballots` AS `More Votes than Ballots (#)`,
  `2013 election pres - precincts`.`vpm 8-12` AS `Average votes per minute (08:00-12:00)`,
  `2013 election pres - precincts`.`vpm 12-17` AS `Average votes per minute (12:00-17:00)`,
  `2013 election pres - precincts`.`vpm 17-20` AS `Average votes per minute (17:00-20:00)`,
  NULL AS `Number of Precincts with votes per minute > 2 (08:00-12:00)`,
  NULL AS `Number of Precincts with votes per minute > 2 (12:00-17:00)`,
  NULL AS `Number of Precincts with votes per minute > 2 (17:00-20:00)`,
  NULL AS `Number of Precincts with votes per minute > 2`,
  NULL AS `Precincts Reported (#)`,
  NULL AS `Precincts Reported (%)`,
  `2013 election pres - precincts`.`1 - Tamaz Bibiluri` AS `Tamaz Bibiluri`,
  `2013 election pres - precincts`.`2 - Giorgi Liluashvili` AS `Giorgi Liluashvili`,
  `2013 election pres - precincts`.`3 - Sergo Javakhidze` AS `Sergo Javakhidze`,
  `2013 election pres - precincts`.`4 - Koba Davitashvili` AS `Koba Davitashvili`,
  `2013 election pres - precincts`.`5 - Davit Bakradze` AS `Davit Bakradze`,
  `2013 election pres - precincts`.`6 - Akaki Asatiani` AS `Akaki Asatiani`,
  `2013 election pres - precincts`.`7 - Nino Chanishvili` AS `Nino Chanishvili`,
  `2013 election pres - precincts`.`8 - Teimuraz Bobokhidze` AS `Teimuraz Bobokhidze`,
  `2013 election pres - precincts`.`9 - Shalva Natelashvili` AS `Shalva Natelashvili`,
  `2013 election pres - precincts`.`10 - Giorgi Targamadze` AS `Giorgi Targamadze`,
  `2013 election pres - precincts`.`11 - Levan Chachua` AS `Levan Chachua`,
  `2013 election pres - precincts`.`12 - Nestan Kirtadze` AS `Nestan Kirtadze`,
  `2013 election pres - precincts`.`13 - Giorgi Chikhladze` AS `Giorgi Chikhladze`,
  `2013 election pres - precincts`.`14 - Nino Burjanadze` AS `Nino Burjanadze`,
  `2013 election pres - precincts`.`15 - Zurab Kharatishvili` AS `Zurab Kharatishvili`,
  `2013 election pres - precincts`.`16 - Mikheil Saluashvili` AS `Mikheil Saluashvili`,
  `2013 election pres - precincts`.`17 - Kartlos Gharibashvili` AS `Kartlos Gharibashvili`,
  `2013 election pres - precincts`.`18 - Mamuka Chokhonelidze` AS `Mamuka Chokhonelidze`,
  `2013 election pres - precincts`.`19 - Avtandil Margiani` AS `Avtandil Margiani`,
  `2013 election pres - precincts`.`20 - Nugzar Avaliani` AS `Nugzar Avaliani`,
  `2013 election pres - precincts`.`21 - Mamuka Melikishvili` AS `Mamuka Melikishvili`,
  `2013 election pres - precincts`.`22 - Teimuraz Mzhavia` AS `Teimuraz Mzhavia`,
  `2013 election pres - precincts`.`41 - Giorgi Margvelashvili` AS `Giorgi Margvelashvili`
  from `2013 election pres - precincts`)
  union
  (select 'Tbilisi District' AS `shape`,
  `2013 election pres - tbilisi district`.`district_id` AS `common_id`,
  `2013 election pres - tbilisi district`.`district_Name` AS `common_name`,
  `2013 election pres - tbilisi district`.`total valid ballots cast` AS `Total Voter Turnout (#)`,
  `2013 election pres - tbilisi district`.`percent voters voting` AS `Total Voter Turnout (%)`,
  `2013 election pres - tbilisi district`.`num invalid ballots from 0-1%` AS `Number of Precincts with Invalid Ballots from 0-1%`,
  `2013 election pres - tbilisi district`.`num invalid ballots from 1-3%` AS `Number of Precincts with Invalid Ballots from 1-3%`,
  `2013 election pres - tbilisi district`.`num invalid ballots from 3-5%` AS `Number of Precincts with Invalid Ballots from 3-5%`,
  `2013 election pres - tbilisi district`.`num invalid ballots >5%` AS `Number of Precincts with Invalid Ballots > 5%`,
  NULL AS `Invalid Ballots (%)`,
  `2013 election pres - tbilisi district`.`num precincts logic fail` AS `Precincts with Validation Errors (#)`,
  `2013 election pres - tbilisi district`.`percent precincts logic fail` AS `Precincts with Validation Errors (%)`,
  `2013 election pres - tbilisi district`.`avg precinct logic fail difference` AS `Average Number of Validation Errors`, 
  NULL AS `Number of Validation Errors`,
  `2013 election pres - tbilisi district`.`num precincts more ballots than votes` AS `Precincts with More Ballots Than Votes (#)`,
  `2013 election pres - tbilisi district`.`percent precincts more ballots than votes` AS `Precincts with More Ballots Than Votes (%)`,
  `2013 election pres - tbilisi district`.`avg precinct difference more ballots than votes` AS `More Ballots Than Votes (Average)`, 
  NULL AS `More Ballots Than Votes (#)`,
  `2013 election pres - tbilisi district`.`num precincts more votes than ballots` AS `Precincts with More Votes than Ballots (#)`,
  `2013 election pres - tbilisi district`.`percent precincts more votes than ballots` AS `Precincts with More Votes than Ballots (%)`,
  `2013 election pres - tbilisi district`.`avg precinct difference more votes than ballots` AS `More Votes than Ballots (Average)`, 
  NULL AS `More Votes than Ballots (#)`,
  NULL AS `Average votes per minute (08:00-12:00)`,
  NULL AS `Average votes per minute (12:00-17:00)`,
  NULL AS `Average votes per minute (17:00-20:00)`,
  `2013 election pres - tbilisi district`.`num precincts vpm 8-12 > 2` AS `Number of Precincts with votes per minute > 2 (08:00-12:00)`,
  `2013 election pres - tbilisi district`.`num precincts vpm 12-17 > 2` AS `Number of Precincts with votes per minute > 2 (12:00-17:00)`,
  `2013 election pres - tbilisi district`.`num precincts vpm 17-20 > 2` AS `Number of Precincts with votes per minute > 2 (17:00-20:00)`,
  `2013 election pres - tbilisi district`.`num precincts vpm > 2` AS `Number of Precincts with votes per minute > 2`,
  `2013 election pres - tbilisi district`.`num_precincts_reported_number` AS `Precincts Reported (#)`,
  `2013 election pres - tbilisi district`.`num_precincts_reported_percent` AS `Precincts Reported (%)`,
  `2013 election pres - tbilisi district`.`1 - Tamaz Bibiluri` AS `Tamaz Bibiluri`,
  `2013 election pres - tbilisi district`.`2 - Giorgi Liluashvili` AS `Giorgi Liluashvili`,
  `2013 election pres - tbilisi district`.`3 - Sergo Javakhidze` AS `Sergo Javakhidze`,
  `2013 election pres - tbilisi district`.`4 - Koba Davitashvili` AS `Koba Davitashvili`,
  `2013 election pres - tbilisi district`.`5 - Davit Bakradze` AS `Davit Bakradze`,
  `2013 election pres - tbilisi district`.`6 - Akaki Asatiani` AS `Akaki Asatiani`,
  `2013 election pres - tbilisi district`.`7 - Nino Chanishvili` AS `Nino Chanishvili`,
  `2013 election pres - tbilisi district`.`8 - Teimuraz Bobokhidze` AS `Teimuraz Bobokhidze`,
  `2013 election pres - tbilisi district`.`9 - Shalva Natelashvili` AS `Shalva Natelashvili`,
  `2013 election pres - tbilisi district`.`10 - Giorgi Targamadze` AS `Giorgi Targamadze`,
  `2013 election pres - tbilisi district`.`11 - Levan Chachua` AS `Levan Chachua`,
  `2013 election pres - tbilisi district`.`12 - Nestan Kirtadze` AS `Nestan Kirtadze`,
  `2013 election pres - tbilisi district`.`13 - Giorgi Chikhladze` AS `Giorgi Chikhladze`,
  `2013 election pres - tbilisi district`.`14 - Nino Burjanadze` AS `Nino Burjanadze`,
  `2013 election pres - tbilisi district`.`15 - Zurab Kharatishvili` AS `Zurab Kharatishvili`,
  `2013 election pres - tbilisi district`.`16 - Mikheil Saluashvili` AS `Mikheil Saluashvili`,
  `2013 election pres - tbilisi district`.`17 - Kartlos Gharibashvili` AS `Kartlos Gharibashvili`,
  `2013 election pres - tbilisi district`.`18 - Mamuka Chokhonelidze` AS `Mamuka Chokhonelidze`,
  `2013 election pres - tbilisi district`.`19 - Avtandil Margiani` AS `Avtandil Margiani`,
  `2013 election pres - tbilisi district`.`20 - Nugzar Avaliani` AS `Nugzar Avaliani`,
  `2013 election pres - tbilisi district`.`21 - Mamuka Melikishvili` AS `Mamuka Melikishvili`,
  `2013 election pres - tbilisi district`.`22 - Teimuraz Mzhavia` AS `Teimuraz Mzhavia`,
  `2013 election pres - tbilisi district`.`41 - Giorgi Margvelashvili` AS `Giorgi Margvelashvili`
  from `2013 election pres - tbilisi district`)
  union
  (select 'Tbilisi Precinct' AS `shape`,
  `2013 election pres - tbilisi precincts`.`precinct_id` AS `common_id`,
  `2013 election pres - tbilisi precincts`.`precinct_name` AS `common_name`,
  `2013 election pres - tbilisi precincts`.`total valid ballots cast` AS `Total Voter Turnout (#)`,
  `2013 election pres - tbilisi precincts`.`percent voters voting` AS `Total Voter Turnout (%)`,
  NULL AS `Number of Precincts with Invalid Ballots from 0-1%`,
  NULL AS `Number of Precincts with Invalid Ballots from 1-3%`,
  NULL AS `Number of Precincts with Invalid Ballots from 3-5%`,
  NULL AS `Number of Precincts with Invalid Ballots > 5%`,
  `2013 election pres - tbilisi precincts`.`percent invalid ballots` AS `Invalid Ballots (%)`,
  NULL AS `Precincts with Validation Errors (#)`,
  NULL AS `Precincts with Validation Errors (%)`,
  NULL AS `Average Number of Validation Errors`, 
  `2013 election pres - tbilisi precincts`.`logic_check_difference` AS `Number of Validation Errors`,
  null AS `Precincts with More Ballots Than Votes (#)`,
  null AS `Precincts with More Ballots Than Votes (%)`,
  null AS `More Ballots Than Votes (Average)`, 
  `2013 election pres - tbilisi precincts`.`more_ballots_than_votes` AS `More Ballots Than Votes (#)`,
  null AS `Precincts with More Votes than Ballots (#)`,
  null AS `Precincts with More Votes than Ballots (%)`,
  null AS `More Votes than Ballots (Average)`, 
  `2013 election pres - tbilisi precincts`.`more_votes_than_ballots` AS `More Votes than Ballots (#)`,
  `2013 election pres - tbilisi precincts`.`vpm 8-12` AS `Average votes per minute (08:00-12:00)`,
  `2013 election pres - tbilisi precincts`.`vpm 12-17` AS `Average votes per minute (12:00-17:00)`,
  `2013 election pres - tbilisi precincts`.`vpm 17-20` AS `Average votes per minute (17:00-20:00)`,
  NULL AS `Number of Precincts with votes per minute > 2 (08:00-12:00)`,
  NULL AS `Number of Precincts with votes per minute > 2 (12:00-17:00)`,
  NULL AS `Number of Precincts with votes per minute > 2 (17:00-20:00)`,
  NULL AS `Number of Precincts with votes per minute > 2`,
  NULL AS `Precincts Reported (#)`,
  NULL AS `Precincts Reported (%)`,
  `2013 election pres - tbilisi precincts`.`1 - Tamaz Bibiluri` AS `Tamaz Bibiluri`,
  `2013 election pres - tbilisi precincts`.`2 - Giorgi Liluashvili` AS `Giorgi Liluashvili`,
  `2013 election pres - tbilisi precincts`.`3 - Sergo Javakhidze` AS `Sergo Javakhidze`,
  `2013 election pres - tbilisi precincts`.`4 - Koba Davitashvili` AS `Koba Davitashvili`,
  `2013 election pres - tbilisi precincts`.`5 - Davit Bakradze` AS `Davit Bakradze`,
  `2013 election pres - tbilisi precincts`.`6 - Akaki Asatiani` AS `Akaki Asatiani`,
  `2013 election pres - tbilisi precincts`.`7 - Nino Chanishvili` AS `Nino Chanishvili`,
  `2013 election pres - tbilisi precincts`.`8 - Teimuraz Bobokhidze` AS `Teimuraz Bobokhidze`,
  `2013 election pres - tbilisi precincts`.`9 - Shalva Natelashvili` AS `Shalva Natelashvili`,
  `2013 election pres - tbilisi precincts`.`10 - Giorgi Targamadze` AS `Giorgi Targamadze`,
  `2013 election pres - tbilisi precincts`.`11 - Levan Chachua` AS `Levan Chachua`,
  `2013 election pres - tbilisi precincts`.`12 - Nestan Kirtadze` AS `Nestan Kirtadze`,
  `2013 election pres - tbilisi precincts`.`13 - Giorgi Chikhladze` AS `Giorgi Chikhladze`,
  `2013 election pres - tbilisi precincts`.`14 - Nino Burjanadze` AS `Nino Burjanadze`,
  `2013 election pres - tbilisi precincts`.`15 - Zurab Kharatishvili` AS `Zurab Kharatishvili`,
  `2013 election pres - tbilisi precincts`.`16 - Mikheil Saluashvili` AS `Mikheil Saluashvili`,
  `2013 election pres - tbilisi precincts`.`17 - Kartlos Gharibashvili` AS `Kartlos Gharibashvili`,
  `2013 election pres - tbilisi precincts`.`18 - Mamuka Chokhonelidze` AS `Mamuka Chokhonelidze`,
  `2013 election pres - tbilisi precincts`.`19 - Avtandil Margiani` AS `Avtandil Margiani`,
  `2013 election pres - tbilisi precincts`.`20 - Nugzar Avaliani` AS `Nugzar Avaliani`,
  `2013 election pres - tbilisi precincts`.`21 - Mamuka Melikishvili` AS `Mamuka Melikishvili`,
  `2013 election pres - tbilisi precincts`.`22 - Teimuraz Mzhavia` AS `Teimuraz Mzhavia`,
  `2013 election pres - tbilisi precincts`.`41 - Giorgi Margvelashvili` AS `Giorgi Margvelashvili`
  from `2013 election pres - tbilisi precincts`);
  