在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1.创建测试表: 复制代码 代码如下: DROP SEQUENCE student_sequence; CREATE SEQUENCE student_sequence START WITH 10000 INCREMENT BY 1; DROP TABLE students; INSERT INTO students (id, first_name, last_name, major, current_credits,grade) INSERT INTO students (id, first_name, last_name, major, current_credits,grade) INSERT INTO students (id, first_name, last_name, major, current_credits,grade) INSERT INTO students (id, first_name, last_name, major, current_credits,grade) commit; 2.查看相应数据 复制代码 代码如下: SQL> select * from students; ID FIRST_NAME LAST_NAME MAJOR CURRENT_CREDITS GR 3.更新语句 复制代码 代码如下: update students set grade = ( select grade from ( select id, case when current_credits > 90 then 'a' when current_credits > 80 then 'b' when current_credits > 70 then 'c' else 'd' end grade from students ) a where a.id = students.id ) / 4.更新后结果 复制代码 代码如下: SQL> select * from students; ID FIRST_NAME LAST_NAME MAJOR CURRENT_CREDITS GR |
请发表评论