有如下表,请对这张表显示那些学生的成绩为及格,那些为不及格
1、创建表,插入数据
sql
CREATE TABLE chapter8 (
id VARCHAR(255) NULL,
name VARCHAR(255) NULL,
class VARCHAR(255) NULL,
score VARCHAR(255) NULL
);
INSERT INTO chapter8 (id, name, class, score) VALUES('E001', '张通', '一班', '98');
INSERT INTO chapter8 (id, name, class, score) VALUES('E002', '李谷', '一班', '68');
INSERT INTO chapter8 (id, name, class, score) VALUES('E003', '孙凤', '一班', '57');
INSERT INTO chapter8 (id, name, class, score) VALUES('E004', '赵恒', '二班', '47');
INSERT INTO chapter8 (id, name, class, score) VALUES('E005', '王娜', '二班', '84');
INSERT INTO chapter8 (id, name, class, score) VALUES('E006', '李伟', '二班', '70');
INSERT INTO chapter8 (id, name, class, score) VALUES('E007', '刘杰', '三班', '50');
INSERT INTO chapter8 (id, name, class, score) VALUES('E008', '薛李', '三班', '92');
INSERT INTO chapter8 (id, name, class, score) VALUES('E009', '裴军', '三班', '35')
2、实现:
sql
select
id,
name,
score ,
if(score>=60,"及格","不及格") result
from chapter8