很简单的存储过程,主要思路如下,@xsid是出入参数,@zcj,@bjpm是返回值(不同的数据库变量定义不一样,自己改吧) select @zcj=sum(cj) from 学生成绩表 where xsid=@xsid select @bjpm=count(xsid) from 学生表 where bjid = (select bjid from 学生表 where xsid=@xsid) and xsid in (select xsid from 学生成绩表 group by xsid having sum(cj)>@zcj)
select @zcj=sum(cj) from 学生成绩表 where xsid=@xsid
select @bjpm=count(xsid)
from 学生表
where bjid = (select bjid from 学生表 where xsid=@xsid)
and xsid in (select xsid from 学生成绩表 group by xsid having sum(cj)>@zcj)