我想在一个成绩表中查询科目没达到标准分的学生详细成绩,有多个科目需要查询,并且存在重复问题,比如物理和化学都没过,就会显示两条。并且要求班级ID=1。求高手解救~~

解决方案 »

  1.   

    select 科目 from 成绩表 where 班级ID=1 and 成绩<标准分 
      

  2.   

    http://topic.csdn.net/u/20080626/00/43d0d10c-28f1-418d-a05b-663880da278a.html?85256
      

  3.   

    数据表名称score
    列名:
    studentNumber
    studentName
    classID
    totalScore
    ChineseScore
    mathScore
    EnglishScore
    physicalScore
    chemistryScore
    biologicalScore
    geographyScore
    historyScore
    politicsScore
    averageScore 我想查询averageScore过60,但是其它单科成绩有低于60的学生详细成绩。并且classID=1。
      

  4.   

    select *
      from score where averageScore>60 and classID=1
     and (ChineseScore<60 or mathScore<60 or EnglishScore<60.....)
      

  5.   

    select studentName,ChineseScore as sc from score where averageScore>60 and classID=1 and ChineseScore<60
    union all
    select studentName,mathScore from score where averageScore>60 and classID=1 and mathScore<60
    union all...
    .....
      

  6.   


    是不是N列就要写N个sql语句?在jsp里处理方法就要写一堆了,有没一个语句可以实现的?
      

  7.   

    select * from 
    (select姓名,课程,分数 from score where averageScore>60 and classID=1
       unpivot (分数 for 课程 in(ChineseScore,mathScore ,.....,politicsScore)) t)
    where 课程<60
      

  8.   

    select * from 
    (select姓名,课程,分数 from score where averageScore>60 and classID=1
       unpivot (分数 for 课程 in(ChineseScore,mathScore ,.....,politicsScore)) t) a
    where 课程<60