这个查询怎么搞,求指导,谢谢 create table Greade(
gid number,
chinese number not null,
match number not null,
english number not null,
primary key (gid)
)
insert into Greade values (1,'45',96,'67');
insert into Greade values (2,'22',76,'45');
insert into Greade values (3,'76',36,'55');
查询的结果要变成 分数小于60 的为不及格 ,大于60 小于80的 为及格,大于等于80的为优秀
例如
gid chinese match english
1 不及格 优秀 及格
求指导,谢谢!
sql
分享到:
------解决方案--------------------
select gid,
CASE
WHEN chinese < 60 THEN
'不及格'
WHEN chinese < 80 THEN
'及格'
ELSE
'优秀'
END as chinese,
CASE
WHEN match < 60 THEN
'不及格'
WHEN match < 80 THEN
'及格'
ELSE
'优秀'
END as match,
CASE
WHEN english < 60 THEN
'不及格'
WHEN english < 80 THEN
'及格'
ELSE
'优秀'
END as english
from Greade;
------解决方案-------------------- SELECT greade.*,Decode(Sign(greade.english-80),0,'優秀',1,'優秀',Decode(Sign(greade.english-60),1,'及格',0,'及格','不及格')) FROM greade; ------解决方案--------------------