3条回答 默认 最新
- danielinbiti 2015-04-25 12:38关注
像下面这样,出来的结果应该是
张三 60 90 80 最低分科目 最高分科目
李四 50 100 80 最低分科目 最高分科目select name,max(最低分) 最低分,max(最高分) 最高分,max(平均分) 平均分 ,max(最低分科目) 最低分科目,max(最高分科目) 最高分科目 from( select name ,case flg when 'min' then score else 0 end as 最低分 ,case flg when 'max' then score else 0 end as 最高分 ,case flg when 'avg' then score else 0 end as 平均分 ,case flg when 'min' then course else null end as 最低分科目 ,case flg when 'max' then course else null end as 最高分科目 from ( select name,course,score,'min' as flg from userscore u, (select name,min(score) minscore from userscore group by name) mu where u.name = mu.name and u.score=mu.score union select name,course,score,'max' as flg from userscore u, (select name,max(score) minscore from userscore group by name) mu where u.name = mu.name and u.score=mu.score union select name,null as course,avg(score) score,'avg' flg from userscore group by name )
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
- ¥50 有数据,怎么建立模型求影响全要素生产率的因素
- ¥50 有数据,怎么用matlab求全要素生产率
- ¥15 TI的insta-spin例程
- ¥15 完成下列问题完成下列问题
- ¥15 C#算法问题, 不知道怎么处理这个数据的转换
- ¥15 YoloV5 第三方库的版本对照问题
- ¥15 请完成下列相关问题!
- ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
- ¥15 求daily translation(DT)偏差订正方法的代码