-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsy18_missing.map.scores(WIP)
177 lines (174 loc) · 5.63 KB
/
sy18_missing.map.scores(WIP)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
-- This query gives the count of students who are currently enrolled and do not have test scores for Winter MAP testing
WITH fall_read AS (
WITH
score AS (
SELECT
student_id,
"nwea_2018_SchoolName",
"nwea_2018_TermName",
"nwea_2018_Discipline",
max("nwea_2018_TestRITScore") AS score
FROM national_assessments.nwea_2018
WHERE
"nwea_2018_TermName" = 'Fall 2017-2018' AND
"nwea_2018_Discipline" = 'Reading'
GROUP BY
student_id,
"nwea_2018_SchoolName",
"nwea_2018_TermName",
"nwea_2018_Discipline"
)
SELECT
score."nwea_2018_SchoolName",
student_session_aff.session_id,
score."nwea_2018_TermName",
score,
score."nwea_2018_Discipline",
local_student_id,
students.first_name,
students.last_name,
student_session_aff.leave_date
FROM students
LEFT JOIN student_session_aff ON students.student_id = student_session_aff.student_id
LEFT JOIN score ON students.student_id = score.student_id
WHERE
-- Only currently enrolled students reading scores from Fall testing
student_session_aff.leave_date > DATE 'today' AND
score."nwea_2018_TermName" = 'Fall 2017-2018' AND
score."nwea_2018_Discipline" = 'Reading'
), winter_read AS (
WITH
score AS (
SELECT
student_id,
"nwea_2018_SchoolName",
"nwea_2018_TermName",
"nwea_2018_Discipline",
max("nwea_2018_TestRITScore") AS score
FROM national_assessments.nwea_2018
WHERE
"nwea_2018_TermName" = 'Winter 2017-2018' AND
"nwea_2018_Discipline" = 'Reading'
GROUP BY
student_id,
"nwea_2018_SchoolName",
"nwea_2018_TermName",
"nwea_2018_Discipline"
)
SELECT
score."nwea_2018_SchoolName",
student_session_aff.session_id,
score."nwea_2018_TermName",
score,
score."nwea_2018_Discipline",
local_student_id,
students.first_name,
students.last_name,
student_session_aff.leave_date
FROM students
LEFT JOIN student_session_aff ON students.student_id = student_session_aff.student_id
LEFT JOIN score ON students.student_id = score.student_id
WHERE
-- Only currently enrolled students reading scores from Fall testing
student_session_aff.leave_date > DATE 'today' AND
score."nwea_2018_TermName" = 'Winter 2017-2018' AND
score."nwea_2018_Discipline" = 'Reading'
), fall_math AS (
WITH
score AS (
SELECT
student_id,
"nwea_2018_SchoolName",
"nwea_2018_TermName",
"nwea_2018_Discipline",
max("nwea_2018_TestRITScore") AS score
FROM national_assessments.nwea_2018
WHERE
"nwea_2018_TermName" = 'Fall 2017-2018' AND
"nwea_2018_Discipline" = 'Mathematics'
GROUP BY
student_id,
"nwea_2018_SchoolName",
"nwea_2018_TermName",
"nwea_2018_Discipline"
)
SELECT
score."nwea_2018_SchoolName",
student_session_aff.session_id,
score."nwea_2018_TermName",
score,
score."nwea_2018_Discipline",
local_student_id,
students.first_name,
students.last_name,
student_session_aff.leave_date
FROM students
LEFT JOIN student_session_aff ON students.student_id = student_session_aff.student_id
LEFT JOIN score ON students.student_id = score.student_id
WHERE
-- Only currently enrolled students reading scores from Fall testing
student_session_aff.leave_date > DATE 'today' AND
score."nwea_2018_TermName" = 'Fall 2017-2018' AND
score."nwea_2018_Discipline" = 'Mathematics'
), winter_math AS (
WITH
score AS (
SELECT
student_id,
"nwea_2018_SchoolName",
"nwea_2018_TermName",
"nwea_2018_Discipline",
max("nwea_2018_TestRITScore") AS score
FROM national_assessments.nwea_2018
WHERE
"nwea_2018_TermName" = 'Winter 2017-2018' AND
"nwea_2018_Discipline" = 'Mathematics'
GROUP BY
student_id,
"nwea_2018_SchoolName",
"nwea_2018_TermName",
"nwea_2018_Discipline"
)
SELECT
score."nwea_2018_SchoolName",
student_session_aff.session_id,
score."nwea_2018_TermName",
score,
score."nwea_2018_Discipline",
local_student_id,
students.first_name,
students.last_name,
student_session_aff.leave_date
FROM students
LEFT JOIN student_session_aff ON students.student_id = student_session_aff.student_id
LEFT JOIN score ON students.student_id = score.student_id
WHERE
-- Only currently enrolled students reading scores from Fall testing
student_session_aff.leave_date > DATE 'today' AND
score."nwea_2018_TermName" = 'Winter 2017-2018' AND
score."nwea_2018_Discipline" = 'Mathematics'
)
SELECT
students.local_student_id,
students.first_name,
students.last_name,
site_name,
fall_read.score AS fall_reading_score,
fall_math.score AS fall_math_score,
winter_read.score AS winter_reading_score,
winter_math.score AS winter_math_score
FROM student_session_aff
LEFT JOIN students ON student_session_aff.student_id = students.student_id
LEFT JOIN sessions ON student_session_aff.session_id = sessions.session_id
LEFT JOIN sites ON sessions.site_id = sites.site_id
LEFT JOIN fall_read ON students.local_student_id = fall_read.local_student_id
LEFT JOIN winter_read ON students.local_student_id = winter_read.local_student_id
LEFT JOIN fall_math ON students.local_student_id = fall_math.local_student_id
LEFT JOIN winter_math ON students.local_student_id = winter_math.local_student_id
WHERE
-- Remove session id constraint for WA
sessions.session_id <> 215 AND
student_session_aff.leave_date > DATE 'today' AND
winter_read.score ISNULL AND
winter_math.score ISNULL
ORDER BY site_name, students.local_student_id