通過實例簡要介紹case函數的用法
DROP SEQUENCE student_sequence;
CREATE SEQUENCE student_sequence START WITH
DROP TABLE students;
CREATE TABLE students (
id NUMBER(
first_name VARCHAR
last_name VARCHAR
major VARCHAR
current_credits NUMBER(
grade varchar
INSERT INTO students (id
VALUES (student_sequence
INSERT INTO students (id
VALUES (student_sequence
INSERT INTO students (id
VALUES (student_sequence
INSERT INTO students (id
VALUES (student_sequence
commit;
SQL> select * from students;
ID FIRST_NAME LAST_NAME MAJOR CURRENT_CREDITS GR
update students
set grade = (
select grade from
(
select id
case when current_credits >
when current_credits >
when current_credits >
else
from students
) a
where a
)
/
SQL> select * from students;
ID FIRST_NAME LAST_NAME MAJOR CURRENT_CREDITS GR
From:http://tw.wingwit.com/Article/program/Oracle/201311/16889.html