建表如下:
create table student(
id int,name varchar2(2 char)
);
create table score(
stuid int,
coureid int,
score int
);
create table course(
id int,
name varchar2(2 char)
);
alter table student modify (name varchar2(4 char));
alter table course modify (name varchar2(4 char));
insert into student values(1,'张三');
insert into student values(2,'李四');
insert into student values(3,'王五');
insert into student values(4,'张三');
insert into course values(1,'语文');
insert into course values(2,'数学');
insert into course values(3,'英语');
insert into SCORE (STUID, COUREID, SCORE) values (1, 1, 100);
insert into SCORE (STUID, COUREID, SCORE) values (1, 2, 40);
insert into SCORE (STUID, COUREID, SCORE) values (1, 3, 50);
insert into SCORE (STUID, COUREID, SCORE) values (2, 1, 90);
insert into SCORE (STUID, COUREID, SCORE) values (2, 2, 80);
insert into SCORE (STUID, COUREID, SCORE) values (3, 1, 60);
insert into SCORE (STUID, COUREID, SCORE) values (3, 3, 60);
select s.stuid,s2.name,avg(score) from score s,student s2 where s.stuid=s2.id group by s.stuid,s2.name order by s.stuid --每个学生的平均成绩。