2016-12-14 77 views
1

我有一个有各种学习和性能改进的学生数据。将有4项研究,每项研究的学生的表现数据将基于5天记录。根据sql中的多行对数据进行分类

下面是表格脚本和值的链接。

Data

Script Link

我想以这样的方式进行分类的学生是如果在研究中的任意两个性能差那么它必须是更糟的是,如果在没有改善任何3项研究都必须没有改善,否则必须改进

任何帮助,高度赞赏

回答

0
select StudentNumber 
     ,case when sum(case when Performance = 'Worsening' then 1 else 0 end) >= 2 
       then 'Worsening' 
       else case when sum(case when Performance = 'Improvement' then 1 else 0 end) >= 3 
          then 'Improvement' 
          else 'No Improvement' 
          end 
       end as Performance 
from tbl_student 
group by StudentNumber 
相关问题