sql 存储过程简单写 - MS-SQL Server / 基础类
题目是 创建一个存储过程,功能是根据输入的参数形式给定的学生从xs,kc和xk表中查询出这些学生的学号姓名和所选课程的课程名和成绩
create proc test_proc2
as
select xs.xh,xsxm,kcm,cj from xs,kc,xk
exec test_proc2 ' ',' ',' ',' ' --''里的具体参数我没写
创建一个存储过程,根据已经输入参数形式给定的学生的学号统计出该学生所选的课程的平均成绩,并有输出参数带回其平均成绩
create pro test_proc3
@xsxh char
as
select avg(cj) from xk where xh=@xsxh group by kch
print cj
exec '050202104'
这样可以吗??
SQL code:
create pro test_proc3
@xsxh varchar(20),
@cj numeric(8,2) output
as
select @cj=avg(cj) from xk where xh=@xsxh
go
--调用
declare @n numeric(8,2)
exec test_proc3 '050202104',@cj=@n output
select @n
SQL code:
--1.
create proc test_proc2
@参数 参数类型
as
select xs.xh,xsxm,kcm,cj from xs,kc,xk where 连接条件 and 参数列名=@参数
GO
exec test_proc2 ' ',' ',' ',' ' --''里的具体参数我没写
--2.
create pro test_proc3
@xsxh varchar(20),
@avgcj int out
as
select @avgcj=avg(cj) from xk where xh=@xsxh group by kch
GO
declare @avgcj int
exec '050202104',@avgcj out
print @avgcj
第二个不用group by kch,没看好,自己去掉
{{
相关问答:
需求如下:
学院 academy(aid,aname)
班级 class(cid,cname,aid)
学生 stu(sid,sname,aid,cid)
住宿区 region(rid,rname)
宿舍楼 build(bid,rid,bnote) bnote是‘男’/‘女’
宿舍 dorm(did,rid,bid,bedn ......
select o_customer,o_price from orders having o_price >=avg(o_price)
select o_customer,o_price from orders where o_price >=(select avg(o_price) from orders)
我感觉没有区别啊,怎么在mysql会有 ......
SQL code:
rs.open "select * from guide where city_name='北京' order by pai desc",conn,1,1
do while not rs.eof or rs.bof
。。
。。
。。
rs.movenext
loop
这个sql语句在wap站里 本身有 ......
在Access的查询中执行下面的语句,无效,提示期待select ,updata ,...
CreateTble C=Answer N="回帖表"
(
C=ID T="INTEGER" P=No M=No N="编号" Z=false,
C=Ques ......