Browse Source

done for today

master
Jared Dunbar 3 years ago
parent
commit
2696e8aa96
Signed by: jared GPG Key ID: CF202CC859BAC692
  1. 134
      11-12-18.sql

134
11-12-18.sql

@ -0,0 +1,134 @@
-- ukprn varchar(8)
-- institution varchar(100)
-- subject varchar(60)
-- level varchar(50)
-- question varchar(10)
-- A_STRONGLY_DISAGREE int(11)
-- A_DISAGREE int(11)
-- A_NEUTRAL int(11)
-- A_AGREE int(11)
-- A_STRONGLY_AGREE int(11)
-- A_NA int(11)
-- CI_MIN int(11)
-- score int(11)
-- CI_MAX int(11)
-- response int(11)
-- sample int(11)
-- aggregate char(1))
-- 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.
-- Q1 prep
SELECT COUNT(*), COUNT(DISTINCT ukprn), COUNT(DISTINCT institution), COUNT(DISTINCT subject), COUNT(DISTINCT level), COUNT(DISTINCT question)
FROM nss;
-- 50946 288 288 21 2 28
-- "let's see if this will work"
SELECT COUNT(*), COUNT(DISTINCT ukprn, subject), COUNT(DISTINCT institution), COUNT(DISTINCT subject), COUNT(DISTINCT level), COUNT(DISTINCT question)
FROM nss;
-- 50946 2055 288 21 2 28
-- "add a question..."
SELECT COUNT(*), COUNT(DISTINCT ukprn, subject, question), COUNT(DISTINCT institution), COUNT(DISTINCT subject), COUNT(DISTINCT level), COUNT(DISTINCT question)
FROM nss;
-- 50946 45726 288 21 2 28
-- level is a reserved word
SELECT COUNT(*), COUNT(DISTINCT ukprn, subject, question, level), COUNT(DISTINCT institution), COUNT(DISTINCT subject), COUNT(DISTINCT level), COUNT(DISTINCT question)
FROM nss;
-- 50946 50946 288 21 2 28
-- finally, we find a suitable primary key (notice the first and second answer are the same now)
-- it's good to know your data - either ask the designer, or make some queries on how the data is structured
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)
FROM nss;
-- score
-- 78.6771 100 5
-- CI_MIN
-- 66.1851 97 1
-- CI_MAX
-- 86.7345 100 16
-- seems like normalized data, nothing that isn't inbetween 0 and 100
-- q1: Show the the percentage who STRONGLY AGREE for Question 1 at 'Edinburgh Napier University' studying '(8) Computer Science'
SELECT A_STRONGLY_AGREE
FROM nss
WHERE question = 'Q01'
AND institution = 'Edinburgh Napier University'
AND subject = '(8) Computer Science';
-- 23
-- q2: Show the institution and subject where the score is at least 100 for question 15
SELECT institution, subject
FROM nss
WHERE score = 100
AND question = 'Q15';
-- q3: Show the institution and score where the score for '(8) Computer Science' is less than 50 for question 'Q15'
SELECT institution, score
FROM nss
WHERE score < 50
AND subject = '(8) Computer Science'
AND question = 'Q15';
-- 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'.
SELECT subject, SUM(response)
FROM nss
WHERE question = 'Q22'
AND subject IN ('(8) Computer Science', '(H) Creative Arts and Design')
GROUP BY subject;
-- (8) Computer Science 10612
-- (H) Creative Arts and Design 34370
-- 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'
SELECT subject, SUM(A_STRONGLY_AGREE * response / 100)
FROM nss
WHERE question = 'Q22'
AND subject IN ('(8) Computer Science', '(H) Creative Arts and Design')
GROUP BY subject;
-- (8) Computer Science 3563.5600
-- (H) Creative Arts and Design 12484.0100
-- 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'
SELECT subject, ROUND(SUM(A_STRONGLY_AGREE * response)/SUM(response))
FROM nss
WHERE question = 'Q22'
AND subject IN ('(8) Computer Science', '(H) Creative Arts and Design')
GROUP BY subject;
-- compare to inaccurate average
SELECT subject, ROUND(SUM(A_STRONGLY_AGREE * response)/SUM(response)) AS pctg_STRONGLY_AGREE, ROUND(AVG(A_STRONGLY_AGREE)) AS non_weighted
FROM nss
WHERE question = 'Q22'
AND subject IN ('(8) Computer Science', '(H) Creative Arts and Design')
GROUP BY subject;
-- this stuff below I was just working on bcause can.
-- q7: Show the average scores for question 'Q22' for each institution that includes 'Manchester' in the name
SELECT institution, ROUND(AVG(score))
FROM nss
WHERE question='Q22'
AND (institution LIKE '%Manchester%')
GROUP BY institution
-- this doesn't work yet
-- q8: Show the institution, sample size, and number of computing students for instititions in Manchester for 'Q01'
SELECT institution, SUM(sample), SUM(response)
FROM nss
WHERE question='Q01'
AND (institution LIKE '%Manchester%')
AND subject = '(8) Computer Science'
GROUP BY institution
-- this doesn't work yet
--
Loading…
Cancel
Save