Browse Source

done for today

Jared Dunbar 2 years ago
parent
commit
2696e8aa96
Signed by: Jared Dunbar <jrddunbr@gmail.com> GPG Key ID: CF202CC859BAC692
1 changed files with 134 additions and 0 deletions
  1. 134
    0
      11-12-18.sql

+ 134
- 0
11-12-18.sql View File

@@ -0,0 +1,134 @@
1
+-- ukprn	varchar(8)
2
+-- institution	varchar(100)
3
+-- subject	varchar(60)
4
+-- level	varchar(50)
5
+-- question	varchar(10)
6
+-- A_STRONGLY_DISAGREE	int(11)
7
+-- A_DISAGREE	int(11)
8
+-- A_NEUTRAL	int(11)
9
+-- A_AGREE	int(11)
10
+-- A_STRONGLY_AGREE	int(11)
11
+-- A_NA	int(11)
12
+-- CI_MIN	int(11)
13
+-- score	int(11)
14
+-- CI_MAX	int(11)
15
+-- response	int(11)
16
+-- sample	int(11)
17
+-- aggregate	char(1))
18
+
19
+-- The National Student Survey http://www.thestudentsurvey.com/ is presented to thousands of graduating students in UK Higher Education. The survey asks 22 questions, students can respond with STRONGLY DISAGREE, DISAGREE, NEUTRAL, AGREE or STRONGLY AGREE. The values in these columns represent PERCENTAGES of the total students who responded with that answer.
20
+
21
+-- Q1 prep
22
+SELECT COUNT(*), COUNT(DISTINCT ukprn), COUNT(DISTINCT institution), COUNT(DISTINCT subject), COUNT(DISTINCT level), COUNT(DISTINCT question)
23
+FROM nss;
24
+-- 50946	288	288	21	2	28
25
+
26
+-- "let's see if this will work"
27
+SELECT COUNT(*), COUNT(DISTINCT ukprn, subject), COUNT(DISTINCT institution), COUNT(DISTINCT subject), COUNT(DISTINCT level), COUNT(DISTINCT question)
28
+FROM nss;
29
+-- 50946	2055	288	21	2	28
30
+
31
+-- "add a question..."
32
+SELECT COUNT(*), COUNT(DISTINCT ukprn, subject, question), COUNT(DISTINCT institution), COUNT(DISTINCT subject), COUNT(DISTINCT level), COUNT(DISTINCT question)
33
+FROM nss;
34
+-- 50946	45726	288	21	2	28
35
+
36
+-- level is a reserved word
37
+SELECT COUNT(*), COUNT(DISTINCT ukprn, subject, question, level), COUNT(DISTINCT institution), COUNT(DISTINCT subject), COUNT(DISTINCT level), COUNT(DISTINCT question)
38
+FROM nss;
39
+-- 50946	50946	288	21	2	28
40
+
41
+-- finally, we find a suitable primary key (notice the first and second answer are the same now)
42
+-- it's good to know your data - either ask the designer, or make some queries on how the data is structured
43
+
44
+SELECT AVG(score), MAX(score), MIN(score), AVG(CI_MIN), MAX(CI_MIN), MIN(CI_MIN), AVG(CI_MAX), MAX(CI_MAX), MIN(CI_MAX)
45
+FROM nss;
46
+-- score
47
+-- 78.6771 100 5
48
+-- CI_MIN
49
+-- 66.1851 97  1
50
+-- CI_MAX
51
+-- 86.7345 100 16
52
+
53
+-- seems like normalized data, nothing that isn't inbetween 0 and 100
54
+
55
+-- q1: Show the the percentage who STRONGLY AGREE for Question 1 at 'Edinburgh Napier University' studying '(8) Computer Science'
56
+SELECT A_STRONGLY_AGREE
57
+FROM nss
58
+WHERE question = 'Q01'
59
+AND institution = 'Edinburgh Napier University'
60
+AND subject = '(8) Computer Science';
61
+-- 23
62
+
63
+-- q2: Show the institution and subject where the score is at least 100 for question 15
64
+SELECT institution, subject
65
+FROM nss
66
+WHERE score = 100
67
+AND question = 'Q15';
68
+
69
+-- q3: Show the institution and score where the score for '(8) Computer Science' is less than 50 for question 'Q15'
70
+SELECT institution, score
71
+FROM nss
72
+WHERE score < 50
73
+AND subject = '(8) Computer Science'
74
+AND question = 'Q15';
75
+
76
+-- q4: Show the subject and total number of students who responded to question 22 for each of the subjects '(8) Computer Science' and '(H) Creative Arts and Design'.
77
+SELECT subject, SUM(response)
78
+FROM nss
79
+WHERE question = 'Q22'
80
+AND subject IN ('(8) Computer Science', '(H) Creative Arts and Design')
81
+GROUP BY subject;
82
+-- (8) Computer Science         10612
83
+-- (H) Creative Arts and Design 34370
84
+
85
+-- q5: Show the subject and total number of studens who A_STRONGLY_AGREE to question 22 for each of the subjects '(8) Computer Science' and '(H) Creative Arts and Design'
86
+SELECT subject, SUM(A_STRONGLY_AGREE * response / 100)
87
+FROM nss
88
+WHERE question = 'Q22'
89
+AND subject IN ('(8) Computer Science', '(H) Creative Arts and Design')
90
+GROUP BY subject;
91
+-- (8) Computer Science         3563.5600
92
+-- (H) Creative Arts and Design 12484.0100
93
+
94
+-- q6: Show the percentage of students who A_STRONGLY_AGREE to question 22 for the subject '(8) Computer Science', and show the same figure for  '(H) Creative Arts and Design'
95
+SELECT subject, ROUND(SUM(A_STRONGLY_AGREE * response)/SUM(response))
96
+FROM nss
97
+WHERE question = 'Q22'
98
+AND subject IN ('(8) Computer Science', '(H) Creative Arts and Design')
99
+GROUP BY subject;
100
+
101
+-- compare to inaccurate average
102
+SELECT subject, ROUND(SUM(A_STRONGLY_AGREE * response)/SUM(response)) AS pctg_STRONGLY_AGREE, ROUND(AVG(A_STRONGLY_AGREE)) AS non_weighted
103
+FROM nss
104
+WHERE question = 'Q22'
105
+AND subject IN ('(8) Computer Science', '(H) Creative Arts and Design')
106
+GROUP BY subject;
107
+
108
+
109
+
110
+-- this stuff below I was just working on bcause can.
111
+
112
+
113
+
114
+-- q7: Show the average scores for question 'Q22' for each institution that includes 'Manchester' in the name
115
+SELECT institution, ROUND(AVG(score))
116
+FROM nss
117
+WHERE question='Q22'
118
+AND (institution LIKE '%Manchester%')
119
+GROUP BY institution
120
+-- this doesn't work yet
121
+
122
+-- q8: Show the institution, sample size, and number of computing students for instititions in Manchester for 'Q01'
123
+SELECT institution, SUM(sample), SUM(response)
124
+FROM nss
125
+WHERE question='Q01'
126
+AND (institution LIKE '%Manchester%')
127
+AND subject = '(8) Computer Science'
128
+GROUP BY institution
129
+-- this doesn't work yet
130
+
131
+
132
+
133
+
134
+--

Loading…
Cancel
Save