列上的运算
列上的运算很简单,比如表student(id number, name varchar2(10), score number);
给所有学生成绩加10分;
update student set score = score+10;
还可以创建视图:
create view v_student select id, name, score+10 as score from student;
现在又多一张表score,里面有每个学生很多科目的成绩score(stu_id number, course_id number, score number),要求创建视图,包含学生的功课总分:
create view v_student as
select id, name, t.total_score from student,
(select stu_id, sum(score) as total_score from score group by stu_id) t where t.stu_id = id;
就要用子查询创建一个临时表。