--函数
alter function xb
(
@xingbie varchar(2)
)
returns table
as
return
( select a.sex,SUM (b.score)as 总分,AVG(b.score)as 平均分
from stu3 as a full join stu4 as b on a .snum=b.cnum
where sex =@xingbie
group by a.sex
)
go
select * from xb ('女')
--存储过程
alter procedure xb1(@xingbie varchar(2))
as
select a.sex,SUM (b.score)as 总分,AVG(b.score)as 平均分
from stu3 as a full join stu4 as b on a .snum=b.cnum
where sex =@xingbie
group by a.sex
go
exec xb1 '女'
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册⭐️ Admin快速开发: https://show.cool-admin.com/
赞 0⭐️ 官方文档: https://cool-js.com
赞 0⭐️ chatgpt在线体验: https://cool-js.com/ai/chat-vip/index.html?r=helloworld
赞 0