create or replace procedure COLLEGE_TOTAL is
--定义一个记录
type t_AuthRec is record(
coid number,
avgscorce number,
maxscorce number,
minscorce number,
totalnum number,
boynum number,
girlnum number
);
--定义记录表下标索引
i binary_integer := -1 ;
--定义记录表类型
type tmp_table_type is table of t_AuthRec index by binary_integer ;
--定义记录表变量
v_tmp_table tmp_table_type ;
--decode分支函数,常用于count()的统计判断cursor v_college_list is select c.collegeid,avg(ts.totalsco),max(ts.totalsco),min(ts.totalsco),c.actual_total,count(decode(sex,0,sex,1,null)) boy,c.actual_total -count(decode(sex,0,sex,1,null)) girl
from college c,mat m,student s,totalscore ts where c.collegeid=m.mat_collegeid and s.stuid=m.stuid and ts.stuid=s.stuid
group by c.collegeid ,c.actual_total
[size=small]--使用avg,max,min,count等统计函数时,必须要有gounp by,否则无法正常输出!![/size]----------------------------------------------------------------------
order by avg(ts.totalsco) desc;
begin
--给记录表变量赋值
for v_record in v_college_list loop
v_tmp_table(i) :=v_record ;
i := i + 1 ;
end loop;
--输出记录表变量的值
for j in v_tmp_table.first..v_tmp_table.last loop
--记录表,输出自定义类型的变量名v_tmp_table(j).coid!!!
Dbms_Output.put_line('院校编号:'||v_tmp_table(j).coid);
Dbms_Output.put_line('平均分数:'||v_tmp_table(j).avgscorce);
Dbms_Output.put_line('最大分数:'||v_tmp_table(j).maxscorce);
Dbms_Output.put_line('最小分数:'||v_tmp_table(j).minscorce);
Dbms_Output.put_line('录取总人数:'||v_tmp_table(j).totalnum);
Dbms_Output.put_line('男人数:'||v_tmp_table(j).boynum);
Dbms_Output.put_line('女人数:'||v_tmp_table(j).girlnum);
end loop;
end COLLEGE_TOTAL;
--过程名和参数:COLLEGE_TOTAL
--功能:按照院校的平均录取分数排序所有院校,统计各院校的最高分数、
--最低分数,招生人数、录取人数、男生人数、女生人数等信息。
分享到:
相关推荐
college_androidPhone_dxstj_download_common_00.apk
college_education009
`college_code` '学校标识码', `college_cn_name` '学校中文名称', `college_en_name` '学校英文名称', `college_short_name` '学校简称', `country_code_2` '国家编码', `college_type` '学校类型' `...
College_Algebra_Demystified_A_Self-Teaching_Guide
An_Improved_Framework_for_Sentiment_Analysis_for_College_Reviews T. Sri Devi, R. Dhanalakshmi, S. Sankar
college_education
College Management System In ...
一个简单的bootstrap项目,静态网页没有后台,可供初学者使用学习
VS2008开发的C#高校宿舍管理系统.本系统是基于C#2008开发的,数据库也是采用MSSQL2008,附有SQL脚本,运行程序前请先在查询分析器运行SQL脚本建立数据库.本高校学生信息管理系统可完成宿舍楼管理、宿舍管理、学生...
Project_College_database
PPT模板
Java大学教程的源代码!!!!!!!! 源代码
这是我自己做的项目,为本校管理学院做的。Jsp动态网站,里面包含聊天室,留言本,信息发布,小游戏等模块。有学生登陆和管理员登陆两个权限。
python爬取网页带合并单元格信息的爬取,使用BS4,然后将获得的初始信息存到硬盘上在进行处理,提高了代码的稳定性;
college_practice_server
College_Minor_Projects
ca_community_college_ncl_per_ftes
Olympic_College_Ashton_Krause_CIS_155_Spring_2021
College_Enquiry_ChatBot College_enquiry_chat-bot是一个简单的基于Web的应用程序,旨在提供有关大学的信息.chat-bot使用自然语言处理和人工神经网络与人类进行对话.chat-bot的响应在某种程度上被编程以训练提供...