—行者 2021-12-07 10:12 采纳率: 0%
浏览 17

mysql存储过程定义变量出错

查询学院不同年份,不同月份,各专业省级、国家级竞赛获奖总人数,各学院的省级获奖情况,各学院的国家级获奖情况,学校获奖省级总人数,学校获奖国家级总人数。

create procedure proc_include(in syear int,in date_begin int,in date_end int)
delimiter $$
begin
declare s_totalnumber int;
declare g_totalnumber int;
select ('学院各专业省级、国家级竞赛获奖总人数')
select college.name,pgrade,major.majorname,COUNT(pgrade) as num
from team,componentinfo,student,major,college
where team.teamid = componentinfo.teamid
and componentinfo.stid = student.stid
and student.majorkey = major.majorkey
and major.collegekey = college.collegekey
and year(ptime) = syear
and month(ptime)>date_begin
and month(ptime)<date_end
group by college.name,majorname,pgrade
having pgrade <> 'NULL'
order by num

select ('各学院的省级获奖情况')
select college.name,pgrade,COUNT(pgrade) as num
from team,componentinfo,student,major,college
where team.teamid = componentinfo.teamid
and componentinfo.stid = student.stid
and student.majorkey = major.majorkey
and major.collegekey = college.collegekey
and year(ptime) = syear
and month(ptime)>date_begin
and month(ptime)<date_end
group by college.name,pgrade
having pgrade <> 'NULL' and pgrade <> '国家级'

select ('各学院的国家级获奖情况')
select college.name,pgrade,COUNT(pgrade) as num
from team,componentinfo,student,major,college
where team.teamid = componentinfo.teamid
and componentinfo.stid = student.stid
and student.majorkey = major.majorkey
and major.collegekey = college.collegekey
and year(ptime)=syear
and month(ptime)>date_begin
and month(ptime)<date_end
group by college.name,pgrade
having pgrade <> 'NULL' and pgrade <> '省级'

select g_totalnumber = COUNT(pgrade)
from team
where year(ptime) = syear
and month(ptime)>date_begin
and month(ptime)<date_end
and pgrade <> 'NULL' and pgrade <> '省级'

select s_totalnumber = COUNT(pgrade)
from team
where year(ptime) = syear
and month(ptime)>date_begin
and month(ptime)<date_end
and pgrade <> 'NULL' and pgrade <> '国家级'

select('学校获奖省级总人数:')
select s_totalnumber
select ('学校获奖国家级总人数:')
select g_totalnumber;
end
$$
delimiter;

img

把变量的@符号去掉不去掉都不行
没有bughttps://img-mid.csdnimg.cn/release/static/image/mid/ask/515027248836148.png "#left")
  • 写回答

1条回答 默认 最新

  • CSDN专家-sinJack 2021-12-07 11:52
    关注
    delimiter $$
    create procedure proc_include(in syear int,in date_begin int,in date_end int)
    begin
    declare s_totalnumber int;
    declare g_totalnumber int;
    

    delimiter $$定义在存储过程外面。

    评论

报告相同问题?

问题事件

  • 创建了问题 12月7日

悬赏问题

  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含