sqlzoo第八+关 NSS Tutorial

第八+关 NSS Tutorial
  • 学生调查表
FieldType
ukprnvarchar(8)
institutionvarchar(100)
subjectvarchar(60)
levelvarchar(50)
questionvarchar(10)
A_STRONGLY_DISAGREEint(11)
A_DISAGREEint(11)
A_NEUTRALint(11)
A_AGREEint(11)
A_STRONGLY_AGREEint(11)
A_NAint(11)
CI_MINint(11)
scoreint(11)
CI_MAXint(11)
responseint(11)
sampleint(11)
aggregatechar(1)
8.1+题目及答案
  1. The example shows the number who responded for:
    question 1
    at ‘Edinburgh Napier University’
    studying ‘(8) Computer Science’
    Show the the percentage who STRONGLY AGREE
SELECT A_STRONGLY_AGREE
  FROM nss
 WHERE question='Q01'
   AND institution='Edinburgh Napier University'
   AND subject='(8) Computer Science'
  1. Show the institution and subject where the score is at least 100 for question 15.
SELECT institution,subject
  FROM nss
 WHERE question='Q15'
   AND score>=100
  1. 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 question='Q15'
   AND score<50
   AND subject='(8) Computer Science'
  1. 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
  1. Show the subject and total number of students who A_STRONGLY_AGREE to question 22 for each of the subjects ‘(8) Computer Science’ and ‘(H) Creative Arts and Design’.
SELECT subject,sum(response*A_STRONGLY_AGREE/100)
  FROM nss
 WHERE question='Q22'
   AND subject in('(8) Computer Science', '(H) Creative Arts and Design') group by subject
  1. Show the percentage of students who A_STRONGLY_AGREE to question 22 for the subject ‘(8) Computer Science’ show the same figure for the subject ‘(H) Creative Arts and Design’.
    Use the ROUND function to show the percentage without decimal places.
SELECT subject,round(sum(response*A_STRONGLY_AGREE)/sum(response),0)
  FROM nss
 WHERE question='Q22'
   AND subject in('(8) Computer Science', '(H) Creative Arts and Design') 
   group by subject
  1. Show the average scores for question ‘Q22’ for each institution that include ‘Manchester’ in the name.
    The column score is a percentage - you must use the method outlined above to multiply the percentage by the response and divide by the total response. Give your answer rounded to the nearest whole number.
SELECT institution,round(sum(response*score )/sum(response),0)
  FROM nss
 WHERE question='Q22'
   AND (institution LIKE '%Manchester%')
group BY institution

  1. Show the institution, the total sample size and the number of computing students for institutions in Manchester for ‘Q01’.
SELECT institution,sum(sample)
	,sum(case when subject =  '(8) Computer Science' then sample else 0 end)
  FROM nss
 WHERE question='Q01'
   AND (institution LIKE '%Manchester%')
group by institution
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值