sql编程问题。
发布网友
发布时间:2022-04-13 05:02
我来回答
共4个回答
热心网友
时间:2022-04-13 06:31
create procere my_pro1(@s_age integer) as
begin
declare @RG numeric(9,2),@AVG numeric(9,2),@i integer
declare my_cur cursor for
select RG from S inner join SC on S.S#=SC.S# where S.AGE >@s_age
Open my_cur
set @AVG=0
set @i=0
fetch my_cur into @RG
while @@fetch_status=0
begin
set @AVG=@AVG+@RG
set @i=@i+1
fetch my_cur into @RG
end
if @i <> 0 set @avg=@avg/@i
select @avg
close my_cur
deallocate my_cur
end
测试通过 别忘记把分划到我的帐户上
热心网友
时间:2022-04-13 07:49
select avg(RG) from ( select distinct S.SN,RG from S,SC where S.SN=SC.SN and AGE>参数)
热心网友
时间:2022-04-13 09:24
select avg(s2.rg) from sc s2,s s1 where s1.s#=s2.s# and s1.age>输入参数)
热心网友
时间:2022-04-13 11:15
CREATE PROC P1(@AGE INT)
AS
SELECT AVG(SC.RG) FROM S JOIN SC ON S.S#=SC.S# WHERE S.AGE>@AGE