我创建了3个表请问这个功能怎么用SQL写出来

shadowdudu 2007-12-07 01:30:38
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分以上的学生学号和姓名以及
这些课程的平均分。
谢谢了
...全文
67 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
shadowdudu 2007-12-07
  • 打赏
  • 举报
回复
感激中~~~
-狙击手- 2007-12-07
  • 打赏
  • 举报
回复
create proc procname
@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

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧