Case When的用法,简单小例子

来源:互联网 发布:linux vi 文件末尾 编辑:程序博客网 时间:2024/05/16 17:31

Oracel,将表中的数据,大于60为及格,小于60为不及格的转化。create table Score(name varchar2(10),yuwen number(10),shuxue number(10),yingyu number(10));insert into Score (NAME, YUWEN, SHUXUE, YINGYU)values ('小明', 10, 70, 100);insert into Score (NAME, YUWEN, SHUXUE, YINGYU)values ('小白', 80, 40, 10);select t.name,(case when t.yuwen>60 then '及格' else '不及格' end) as 语文,(case when t.shuxue>60 then '及格' else '不及格' end) as 数学,(case when t.yingyu>60 then '及格' else '不及格' end) as 英语from Score t;

原创粉丝点击