1、
select top 1 student.name from student join examscore on student.studentid=examscore.studentid
join course on course.courseid=examscore.courseid where course.name='课程a' order by examscore.score desc2、
select student.name from student join examscore on student.studentid=examscore.studentid join course on course.courseid=examscore.courseid where course.name='课程a' and examscore.score>(
select avg(examscore.score) from examscore join course on course.courseid=examscore.courseid where course.name='课程a')

解决方案 »

  1.   

    一问:要求用一个语句求出课程a的分数最高的学生的名称select name from student
    where studentid in(select studentid from(
    select top 1 studentid,max(score) as aa from examscore
      where courseid=(select courseid from course where coursename='a')
      group by studentid order by aa desc) a)
      

  2.   

    二问:要求用一个语句求出课程a中分数大于平均分的学生的名称select name from student
    where studentid in(select studentid from examscore
      where courseid=(select courseid from course where coursename='a') 
        and score>(select avg(score) from examscore
      where courseid=(select courseid from course where coursename='a') 
    ))
      

  3.   

    二问:要求用一个语句求出课程a中分数大于平均分的学生的名称
    1.求出课程a的平均分
       select avg(examscore.score) from examscore join course on   
       course.courseid=examscore.courseid where course.name='课程a'
    2.课程a中分数大于平均分的学生的名称
       select student.name from student join examscore on   
       student.studentid=examscore.studentid join course on   
       course.courseid=examscore.courseid where 
         course.name='课程a' and 
         examscore.score>()
      

  4.   

    一问:要求用一个语句求出课程a的分数最高的学生的名称
    1.求出课程a的最高分
        select max(examscore.score) from examscore join course on   
        course.courseid=examscore.courseid where course.name='课程a'
    2.课程a中分数等于最高分的学生的名称
       select student.name from student join examscore on   
       student.studentid=examscore.studentid join course on   
       course.courseid=examscore.courseid where 
         course.name='课程a' and 
         examscore.score=()