计算001号专业的学生平均成绩查询001号专业的学生的最高分数查询所有的专业号及相应的分数
类似这样的问题  应该怎么考虑?
SQL语句该怎么写?   PS :   条件可以自己假设  

解决方案 »

  1.   


    --平均成绩
    select stuid, avg(score) from studentinfo where stuid = '001'
    --最高分数
    select stuid, max(score) from studentinfo where stuid = '001'
    --查询所有
    select stuid, classid, score from studentinfo where stuid = '001'
      

  2.   

    SELECT AVG(成绩) from tb where 专业='001'select max(分数) from tb where 专业='001'select 专业号,分数 from tb
      

  3.   

    --1
    select 专业,avg(成绩)from tb where 专业='001' group by 专业
    --2
    select top 1 专业,sum(成绩) from tb where 专业='001' group by 专业 order by sum(成绩)desc
    --3
    select 专业,avg(成绩)from tb group by 专业
      

  4.   

    1、avg
    2、max
    3、没明白要什么
      

  5.   


    假设此表有如下字段:sno,学号,s,分数,sspecial,专业
    1.select avg(s) from tb where sspecial='001'
    2.select max(s) from tb where sspecial='001'
    3.
    --查询所有专业的平均分
    select sspecial,avg(s) from tb group by sspecial
    --查询所有专业的最高分
    select sspecial,max(s) from tb grop by sspecial
      

  6.   


    呵呵,这些都是我们第一学期刚刚学习SQL这门结构化查询语言时候练的基础题目。