use StudentManager
go
if exists(select * from sysobjects where name='usp_ScoreQuery')
drop procedure usp_ScoreQuery
go
create procedure usp_ScoreQuery --创建存储过程
as
--查询考试信息
select Students.StudentId,StudentName,ClassName,
ScoreSum=(CSharp+SQLServerDB) from Students
inner join StudentClass on StudentClass.ClassId=Students.ClassId
inner join ScoreList on Students.StudentId=ScoreList.StudentId
order by ScoreSum DESC
--统计分析考试信息
select StudentClass.ClassId,C#Avg=avg(CSharp),DBAvg=avg(SQLServerDB) into #scoreTemp
from StudentClass
inner join Students on StudentClass.ClassId=Students.ClassId
inner join ScoreList on ScoreList.StudentId=Students.StudentId
group by StudentClass.ClassId order by ClassId
select ClassName,C#Avg,DBAvg from #scoreTemp
inner join StudentClass on StudentClass.ClassId=#scoreTemp.ClassId
go
exec usp_ScoreQuery --调用存储过程
这里的  into #scoreTemp  是把查询的数据放入到临时表中
 

T-SQL 无参数的存储过程的创建和执行的更多相关文章

  1. sqlserver 带输出参数的存储过程的创建与执行

    创建 use StudentManager go if exists(select * from sysobjects where name='usp_ScoreQuery4') drop proce ...

  2. T-SQL 有参数存储过程的创建与执行

    use StudentManager go if exists(select * from sysobjects where name='usp_ScoreQuery2') drop procedur ...

  3. 2019-03-19 SQL Server简单存储过程的创建 删除 执行

    --创建名为 Get 的有输入参数的存储过程 create proc Get --设置默认值 @TrustId int ='001' as begin select * from [DealStruc ...

  4. ORACLE存储过程的创建和执行的简单示例和一些注意点

    此示例的主要目的主要是为了了解在PL/SQL环境下怎么创建和执行存储过程. 存储过程所涉及的DataTable: 第一步:创建游标变量 游标是ORACLE系统在内存中开辟的一个工作区,主要用来存储SE ...

  5. SQL关于触发器及存储过程的创建

    使用T-SQL语句来创建触发器   基本语句如下﹕ create trigger trigger_name on {table_name | view_name} {for | After | Ins ...

  6. 在PL/SQL中调用Oracle存储过程

    存储过程 1 什么是存储过程? 用于在数据库中完成特定的操作或者任务.是一个PLSQL程序块,可以永久的保存在数据库中以供其他程序调用. 2 存储过程的参数模式 存储过程的参数特性: IN类型的参数 ...

  7. ASP.NET LinqDataSource数据绑定后,遇到[MissingMethodException: 没有为该对象定义无参数的构造函数。]问题。

    问题出现的情形:LinqDataSource数据绑定到DetailsView或GridView均出错,错误如下: “/”应用程序中的服务器错误. 没有为该对象定义无参数的构造函数. 说明: 执行当前 ...

  8. Oracle存储过程的调用和执行

    1.什么是存储过程: 用于在数据库中完成特定的操作或者任务.是一个PLSQL程序块,可以永久的保存在数据库中以供其他程序调用. 2.无参存储过程的使用: Normal 0 7.8 磅 0 2 fals ...

  9. 使用SQL Server2014作业定时执行无参的存储过程

    一.存储过程 1.新建存储过程 按照下图找到存储过程,右键“新建”选择”存储过程” 此时在右侧会打开一个窗口,如下图. 2.填写创建存储过程语句 填写存储过程名称,因为是无参的存储过程,所以把参数部分 ...

随机推荐

  1. 系统限制和选项limit(一)

    从shell中获取系统限制和选项 终端输入getconf value [pathname] [root@bogon code]# getconf ARG_MAX 2097152 [root@bogon ...

  2. 内置函数——filter和map

    filter filter()函数接收一个函数 f 和一个list,这个函数 f 的作用是对每个元素进行判断,返回 True或 False  ,  filter()根据判断结果自动过滤掉不符合条件的元 ...

  3. GCC related commands

    GCC   -l  option is to link the library. It can use for static and share link.  Link -l with library ...

  4. php7 php-fpm 重启

    PHP7中php.ini.php-fpm和www.conf的配置 http://www.tuicool.com/articles/NjmQNj6 php-fpm 关闭:  kill -SIGINT ` ...

  5. 记一次服务器路由跟踪 (2019-01-23 TODO)

    记一次服务器路由跟踪 有用户反馈网站 无法访问. 现象如下: ping 没有反馈,确认了可以 ping 通其它的网站. tracert 跟踪到服务器商的内部就没的反应了. 同样一家的服务器商,另外一台 ...

  6. 如果忘记了mysql密码怎么办?

    F:\wamp\bin\mysql\mysql5.6.12\bin\mysqld.exe --init-file=resetmysqlpass.txtpause UPDATE mysql.user S ...

  7. LOJ 3055 「HNOI2019」JOJO—— kmp自动机+主席树

    题目:https://loj.ac/problem/3055 先写了暴力.本来想的是 n<=300 的那个在树上暴力维护好整个字符串, x=1 的那个用主席树维护好字符串和 nxt 数组.但 x ...

  8. Maven 环境隔离实践

    现在将SpringMVC中Maven环境隔离实践总结如下: 1. 在pom中配置 <resources> <resource> <directory>src/mai ...

  9. format()的简单实用 笔记

    # 关于format和format_map的使用# 如果要使用输出的字符串对其不仅仅是可以使用format,还可以使用ljust/rjust/center来处理,输出当然也可以是使用%来进行操作,但是 ...

  10. Linux下nohup日志输出过大问题解决方案

    转载自:http://blog.csdn.net/shawnhu007/article/details/50971084 最近在一hadoop测试集群运行一个spark streaming程序,然后使 ...