sql 已有现表,成绩分类成不及格中等良好优秀怎么办?

2024-11-16 18:59:34
推荐回答(1个)
回答1:

score 代表成绩栏位
select case

when score < 60 then '不及格'

when score>60 and score<=80 then'中等'

when score>80 and score<=90 then'良好'

else '优秀'

end from 现表

spl其它语句列:

数据库:CREATE DATABASE database-name

创建表:create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)

删除新表:drop table tabname

增加:Alter table tabname add column col type

设主键:Alter table tabname add primary key(col)

删除主键:Alter table tabname drop primary key(col)

删除索引:drop index idxname

创建视图:create view viewname as select statement

删除视图:drop view viewname