当前位置:   article > 正文

SQL Zoo 8+.NSS Tutorial

SQL Zoo 8+.NSS Tutorial

以下数据来自SQL Zoo

1.at 'Edinburgh Napier University',studying '(8) Computer Science',Show the the percentage who STRONGLY AGREE.(在爱丁堡纳皮尔大学,学习“计算机科学”,显示STRONGLY AGREE的百分比)

  1. SELECT A_STRONGLY_AGREE
  2. FROM nss
  3. WHERE question='Q01'
  4. AND institution='Edinburgh Napier University'
  5. AND subject='(8) Computer Science'

2.Show the institution and subject where the score is at least 100 for question 15.(列出第15题得分至少为100分的院校和科目)

  1. SELECT institution,subject
  2. FROM nss
  3. WHERE question='Q15'
  4. AND score >=100

3.Show the institution and score where the score for '(8) Computer Science' is less than 50 for question 'Q15'(在“Q15”题中,显示“(8)计算机科学”得分低于50分的院校和分数)

  1. SELECT institution,score
  2. FROM nss
  3. WHERE question='Q15'
  4. AND score <50
  5. AND subject='(8) Computer Science'

4.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'.(请列出在“(8)计算机科学”和“(H)创意艺术与设计”两个科目中回答问题22的学生总数)

  1. SELECT subject,sum(response)
  2. FROM nss
  3. WHERE question='Q22'
  4. AND (subject='(8) Computer Science' or subject = '(H) Creative Arts and Design')
  5. group by subject

5.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'.(请列出在“(8)计算机科学”和“(H)创意艺术与设计”两个科目中强烈同意问题22的科目和学生总数)

  1. SELECT subject,sum(response*A_STRONGLY_AGREE)/100
  2. FROM nss
  3. WHERE question='Q22'
  4. AND (subject='(8) Computer Science' or subject = '(H) Creative Arts and Design')
  5. group by subject

6.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'.(显示在“(8)计算机科学”科目中强烈同意问题22的学生的百分比,在“(H)创意艺术与设计”科目中显示相同的数字)

  1. SELECT subject,
  2. ROUND(SUM(response*A_STRONGLY_AGREE) / SUM(response))
  3. FROM nss
  4. WHERE question = 'Q22'
  5. AND (subject = '(H) Creative Arts and Design' OR subject = '(8) Computer Science')
  6. GROUP BY subject

7.Show the average scores for question 'Q22' for each institution that include 'Manchester' in the name.(显示名称中包含“曼彻斯特”的每所院校在“Q22”问题上的平均得分)

  1. SELECT institution,round(sum(score*response)/sum(response))
  2. FROM nss
  3. WHERE question='Q22'
  4. AND (institution LIKE '%Manchester%')
  5. group BY institution
  6. order by institution

8.Show the institution, the total sample size and the number of computing students for institutions in Manchester for 'Q01'.(显示该院校、总样本量和曼彻斯特院校计算机专业学生的数量)

  1. SELECT institution,sum(sample),SUM(CASE WHEN subject = '(8) Computer Science' THEN sample ELSE NULL END)
  2. FROM nss
  3. WHERE question='Q01'
  4. AND (institution LIKE '%Manchester%')
  5. group by institution

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/967095
推荐阅读
相关标签
  

闽ICP备14008679号