oracle的case函数create sequence STUDENT_SEQUENCE;
CREATE TABLE students (
id NUMBER(5) PRIMARY KEY,
stu_name VARCHAR2(20),
score NUMBER(10,0),
grade varchar2(2));
INSERT INTO students (id, stu_name, score, grade)
VALUES (student_sequence.NEXTVAL, 'Scott', 98,null);
INSERT INTO students (id, stu_name, score, grade)
VALUES (student_sequence.NEXTVAL, 'Margaret', 88,null);
INSERT INTO students (id, stu_name, score, grade)
VALUES (student_sequence.NEXTVAL, 'Joanne', 75,null);
INSERT INTO students (id, stu_name, score, grade)
VALUES (student_sequence.NEXTVAL, 'Manish', 66,null);
update students
set grade =
case when score > 90 then 'a'
when score > 80 then 'b'
when score > 70 then 'c'
else 'd' end
oracle的case结构
begin
case when 2<1 then
dbms_output.put_line('y');
else
dbms_output.put_line('n');
end case;
end;
/
这个case when ... end case 和上边的case when ... end是不同的。
posted on 2007-04-13 10:55
Lib 阅读(979)
评论(0) 编辑 收藏 所属分类:
DataBase