青灯烛影 2020-04-21 17:25 采纳率: 78.6%
浏览 195
已采纳

求教各位大佬,这个sql,请问这个该怎么写呀!谢谢!

图片说明

  • 写回答

1条回答 默认 最新

  • bj_0163_bj 2020-04-21 19:06
    关注

    第一题

    select *
    from (
    select class_id,student_id,name,score_sum,rank() over (partition by class_id order by score_sum desc) rw 
    from (
    select CLASS.class_id,STUDENT.student_id,STUDENT.name,sum(score) score_sum
    from CLASS 
    join CLASS_STUDENT
    on CLASS.class_id=CLASS_STUDENT.class_id
    join STUDENT
    on CLASS_STUDENT.student_id=STUDENT.student_id
    join STUDENT_SCORE
    on STUDENT.student_id=STUDENT_SCORE.student_id
    group by CLASS.class_id,STUDENT.student_id,STUDENT.name
    ) t 
    ) t2
    where rw=1
    
    

    第二题

    select *
    from (
    select CLASS.class_id,STUDENT.student_id,STUDENT.name,STUDEN_SCORE.course,score,
    rank() over (partition by class_id,STUDEN_SCORE.course order by score desc) rw 
    from CLASS 
    join CLASS_STUDENT
    on CLASS.class_id=CLASS_STUDENT.class_id
    join STUDENT
    on CLASS_STUDENT.student_id=STUDENT.student_id
    join STUDENT_SCORE
    on STUDENT.student_id=STUDENT_SCORE.student_id
    ) t 
    where rw=1
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 visionmaster启动失败,提示为“机器不满足授权而被禁用”
  • ¥50 用logisim设计16位单时钟周期cpu
  • ¥15 IDEA中圈复杂度如何具体设置
  • ¥50 labview采集不了数据
  • ¥15 请上面代码做什么处理或什么混淆
  • ¥15 英雄联盟自定义房间置顶
  • ¥15 W5500网线插上无反应
  • ¥15 如何用字典的Key,显示在WPF的xaml中
  • ¥15 weautomate读取Excel表格信息然后填写到网页一直报错,如何解决?
  • ¥15 C#如何在Webview2中获取网页验证码