1.
create table student
(
stuid int primary key identity(1,1) not null,
stuname varchar(20)
)
create table course
(
couid int primary key identity(1,1) not null,
couname varchar(20)
)
create table sc
(
stuid int ,
couid int,
score decimal(10,2)
)
alter table sc
add constraint fk_sc_stuid foreign key (stuid)
references student(stuid) on update cascade;
alter table sc
add constraint fk_sc_couid foreign key (couid)
references course(couid) on update cascade;
2. alter table sc add level varchar(5)
3.不太理解题目的意思,不好意思
4.查询“大学语文”成绩大于80分学生的姓名,写出SQL语句
select stuname from student s inner join sc on s.stuid = sc.stuid
join course c on c.couid = sc.couid where couname='大学语文' and score > 80
查询学生各科平均成绩并按平均成绩降序排序,写出SQL语句。
select stuid,avg(score) as '平均成绩' from sc,student s where sc.stuid=s.stuid group by stuid order by avg(score) desc