-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert_from_imported_tables.sql
More file actions
76 lines (72 loc) · 1.67 KB
/
insert_from_imported_tables.sql
File metadata and controls
76 lines (72 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
insert into `schools` (
select school_id,
case school_short_name
when 'BO' then 'Bottenfield'
when 'CB' then 'Carrie Busey'
when 'ST' then 'Stratton'
when 'DH' then 'Dr. Howard'
when 'GH' then 'Garden Hills'
when 'KW' then 'Kenwood'
when 'RO' then 'Robeson'
when 'SS' then 'Southside'
when 'WA' then 'Washington'
when 'WV' then 'Westview'
when 'BA' then 'Barkstall'
else '' end school_name,
school_short_name
from (
SELECT `UNIT 4` school_id, `TEST 2` school_short_name, sum(D) capacity
FROM `SC`
WHERE `UNIT 4` is not null and `UNIT 4` != 'CODE' and `UNIT 4` != 'TOTALS:'
group by `UNIT 4`, `TEST 2`) a )
;
-- add an entry for an 'unassigned' school (some data elements use 0 to indicate the unassigned status
insert into `schools` values (0,'No school','N/A');
insert into `school_capacity` (
select school_id,
'2012',
capacity
from (
SELECT `UNIT 4` school_id, `TEST 2` school_short_name, sum(D) capacity
FROM `SC`
WHERE `UNIT 4` is not null and `UNIT 4` != 'CODE' and `UNIT 4` != 'TOTALS:'
group by `UNIT 4`, `TEST 2`) a )
;
-- insert the preassignments
insert into choices (
select '2012' year,
null choice1,
null choice2,
null choice3,
null choice4,
null choice5,
null choice6,
null choice7,
null choice8,
null choice9,
null choice10,
null choice11,
null choice12,
preasg assigned_school
from `apps2012_run3`
where preasg != 0)
;
-- insert the "real" choices
insert into choices (
select '2012' year,
ch1sch choice1,
ch2sch choice2,
ch3sch choice3,
ch4sch choice4,
ch5sch choice5,
null choice6,
null choice7,
null choice8,
null choice9,
null choice10,
null choice11,
null choice12,
asgsch assigned_school
from `apps2012_run3`
where preasg = 0
);