sql条件查询语句的简单实例
发布日期:2021-12-31 11:59 | 文章来源:站长之家
复制代码 代码如下:
//创建成绩表
create table result(
stu_id varchar2(20) not null,
china number(9,2) null,
math number(9,2) null,
english number(9,2) null
); //插入数据
insert into result values('0001',60,20,80);
insert into result values('0002',80,60,80);
insert into result values('0003',20,85,80);
select *from result; //条件查询
select stu_id,(case
when china>80 then '优秀'
when china>=60 then '及格'
when china<60 then '不及格'
end) as 语文 ,
(case
when math>80 then '优秀'
when math>=60 then '及格'
when math<60 then '不及格'
end )as 数学 ,
(case
when english>80 then '优秀'
when english>=60 then '及格'
when english<60 then '不及格'
end) as 英语
from result
版权声明:本站文章来源标注为YINGSOO的内容版权均为本站所有,欢迎引用、转载,请保持原文完整并注明来源及原文链接。禁止复制或仿造本网站,禁止在非www.yingsoo.com所属的服务器上建立镜像,否则将依法追究法律责任。本站部分内容来源于网友推荐、互联网收集整理而来,仅供学习参考,不代表本站立场,如有内容涉嫌侵权,请联系alex-e#qq.com处理。
相关文章