Thursday, October 2, 2014

Summary view of a voterdb

Summary voterdb statistics for this political piece.

-- Active, Inactive,42nd,40th totals
drop view zA;
drop view zI;
drop view z42;
drop view z40;
-- 42nd Voted in 2013GE; Voted in both 2013GE and 2012GE
-- 42nd other ...
drop view z1ld42;
drop view z2ld42;
drop view z0ld42;
drop view z02ld42;
drop view zNULL1ld42;
drop view zNULL2ld42;
-- Voted in 2013GE; Voted in both 2013GE and 2012GE
-- Not Returned in 2013GE; Not Returned in both 2013GE and 2012GE
-- NA in 2013GE; NA in both 2013GE and 2012GE
drop view z1;
drop view z2;
drop view z0;
drop view z02;
drop view zNULL1;
drop view zNULL2;

Create view zA AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A'
Group By precinctid Order By Count DESC;

Create view zI AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='I'
Group By precinctid Order By Count DESC;

Create view z42 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and precinctid in
(Select precincts42 from ld42)
Group By precinctid Order By Count DESC;

Create view z40 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and  precinctid not in
(Select precincts42 from ld42)
Group By precinctid Order By Count DESC;

Create view z1ld42 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = '1' and precinctid in
(Select precincts42 from ld42)
Group By precinctid Order By Count DESC;

Create view z2ld42 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = '1' and ballotcounted_2 = '1' and precinctid in
(Select precincts42 from ld42)
Group By precinctid Order By Count DESC;

Create view z0ld42 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = '0' and precinctid in
(Select precincts42 from ld42)
Group By precinctid Order By Count DESC;

Create view z02ld42 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = '0' and ballotcounted_2 = '0' and precinctid in
(Select precincts42 from ld42)
Group By precinctid Order By Count DESC;

Create view zNULL1ld42 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = '' and precinctid in
(Select precincts42 from ld42)
Group By precinctid Order By Count DESC;

Create view zNULL2ld42 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = '' and ballotcounted_2 = '' and precinctid in
(Select precincts42 from ld42)
Group By precinctid Order By Count DESC;

Create view z1 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = '1'
Group By precinctid Order By Count DESC;

Create view z2 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = '1' and ballotcounted_2 = '1'
Group By precinctid Order By Count DESC;

Create view z0 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = '0'
Group By precinctid Order By Count DESC;

Create view z02 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = '0' and ballotcounted_2 = '0'
Group By precinctid Order By Count DESC;

Create view zNULL1 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = ''
Group By precinctid Order By Count DESC;

Create view zNULL2 AS
Select Count(precinctid),precinctid
from voterdb100214
where statuscode ='A' and ballotcounted_1 = '' and ballotcounted_2 = ''
Group By precinctid Order By Count DESC;

-- All Active
Select Sum(Count) from zA;
-- All Inactive
Select Sum(Count) from zI;
-- All Active in 42nd
Select Sum(Count) from z42;
-- All Active in 40th
Select Sum(Count) from z40;
-- All Active in 42nd who voted in 2013GE
Select Sum(Count) from z142ld;
-- All Active in 42nd who voted in 2013GE and 2012GE
Select Sum(Count) from z242ld;
-- All Active in 42nd who did not vote in 2013GE
Select Sum(Count) from z0ld42;
-- All Active in 42nd who did not vote in 2013GE and 2012GE
Select Sum(Count) from z02ld42;
-- All Active in 42nd who were not registered in 2013GE
Select Sum(Count) from zNULL1ld42;
-- All Active in 42nd who were not registered in 2013GE or 2012GE
Select Sum(Count) from zNULL2ld42;

-- All Active who voted in 2013GE
Select Sum(Count) from z1;
-- All Active who voted in 2013GE and 2012GE
Select Sum(Count) from z2;
-- All Active who did not return a ballot in 2013GE
Select Sum(Count) from z0;
--All Active who did not return a ballot in 2013GE or 2012GE
Select Sum(Count) from z02;
-- All Active who were not registered in 2013GE
Select Sum(Count) from zNULL1;
-- All Active who were not registered in 2013GE or 2012GE
Select Sum(Count) from zNULL2;



No comments:

Post a Comment