use xscj
--create table xs
--( 学号 char(6) not null primary key,
-- 姓名 char(8) not null,
-- 课程名 char(6) not null,
-- 性别 BIT not NULL,
-- 出生时间 smalldatetime not null,
--)
--use xscj
--create table kc
--(课程号 char(6) not null primary key,
--课程名 char(6) not null,
--开课学期 int not null,
--学时 int not null,
--学分 int not null,)
--use xscj
--create table xs_kc
--(学号 char(6) not null primary key(学号,课程号),
--课程号 char(10) not null,
--选课信息 char(10) not null,
--)
自定义存储过程,参数为@num int,@semes char(12),@score int ,分别表示课程数目、开课季节、分数:
实现查询@Semes季节,@num门课程在@score分以上的学生学号和姓名以及
这些课程的平均分。
谢谢了
--create table xs
--( 学号 char(6) not null primary key,
-- 姓名 char(8) not null,
-- 课程名 char(6) not null,
-- 性别 BIT not NULL,
-- 出生时间 smalldatetime not null,
--)
--use xscj
--create table kc
--(课程号 char(6) not null primary key,
--课程名 char(6) not null,
--开课学期 int not null,
--学时 int not null,
--学分 int not null,)
--use xscj
--create table xs_kc
--(学号 char(6) not null primary key(学号,课程号),
--课程号 char(10) not null,
--选课信息 char(10) not null,
--)
自定义存储过程,参数为@num int,@semes char(12),@score int ,分别表示课程数目、开课季节、分数:
实现查询@Semes季节,@num门课程在@score分以上的学生学号和姓名以及
这些课程的平均分。
谢谢了
@num int,
@semes char(12),
@score int
as
begin
select a.*,avg(score) as avg_score
from xs a
left join xscj b on a.学号 = b.学号
left join kc c on b.课程号 = c.课程号
where b.课程号 = @num and b.开课学期= @semes and b.score > @score
group by a.学号,a.姓名,a.课程名,a.性别 ,a.出生时间 end