class_t(classid,classname)
       g1        一班
       g2        二班
       g3        三班
       ...       ...
student_t(studentid,studentname,classid)
       101 张三 g1
       102 李四 g2
       103 王武 g3
       ... ...  ...
course_t(courseid,coursename)
       s1     数学
       s2     英语
       s3     化学
       ...    ...  
score_t(studentid,courseid,score)
       101 s1 80  
       101 s2 70   
       101 s3 90   
       101 ...  ..  6、若对成绩进行等级划分,90以上为优,80-90为良,60-80为及格,60以下为不及格;
   6.1、将成绩表按等级显示出来
select a.classname,b.studentname,成绩情况=
case c.score
when 'c.score>90' then '优'
when 'c.score>=80 and c.score<=90' then '良'
when 'c.score>=60 and c.score<=80' then '及格'
when 'c.score<60' then '不及格'
end
from class_t A,student_t B,score_t C
where a.classid=b.classid and b.studentid=c.studentid错误提示:服务器: 消息 245,级别 16,状态 1,行 1
将 varchar 值 'c.score>90' 转换为数据类型为 int 的列时发生语法错误。请问这个问题怎么解决呢?

解决方案 »

  1.   

    select a.classname,b.studentname,成绩情况=
    case c.score
    when 'c.score>90' then '优'
    when 'c.score>=80 and c.score<=90' then '良'
    when 'c.score>=60 and c.score<=80' then '及格'
    when 'c.score<60' then '不及格'
    end case
    from class_t A,student_t B,score_t C
    where a.classid=b.classid and b.studentid=c.studentid
      

  2.   

    select a.classname,b.studentname,成绩情况=
    case 
    when c.score>90 then '优'
    when c.score>=80 and c.score<=90 then '良'
    when c.score>=60 and c.score<=80 then '及格'
    when c.score<60 then '不及格'
    end
    from class_t A,student_t B,score_t C
    where a.classid=b.classid and b.studentid=c.studentid
      

  3.   

    错了,晕
    select a.classname,b.studentname,成绩情况=
    case c.score
    when c.score>90 then '优'
    when c.score>=80 and c.score<=90 then '良'
    when c.score>=60 and c.score<=80 then '及格'
    when c.score<60 then '不及格'
    end 
    from class_t A,student_t B,score_t C
    where a.classid=b.classid and b.studentid=c.studentid
      

  4.   

    select a.classname,b.studentname,成绩情况=
    case c.score
    when c.score>90 then '优'
    when c.score>=80 and c.score<=90 then '良'
    when c.score>=60 and c.score<=80 then '及格'
    when c.score<60 then '不及格'
    end
    from class_t A,student_t B,score_t C
    where a.classid=b.classid and b.studentid=c.studentid