zoukankan      html  css  js  c++  java
  • 数据库(十一)

    --根据学生选课题目写一个存储过程,输入教师编号
    --判断所教学生的及格率,80分及格,如果及格率超过
    --50%,职称上升一级,否则降一级
    alter proc pingji
    @tno varchar(20)
    as
    begin
    declare @cno varchar(20)
    select @cno=cno from Course where Tno=@tno
    declare @yxcount int
    select @yxcount=count(*) from Score where Cno=@cno and Degree>=70
    declare @zcount int
    select @zcount=COUNT(*) from Score where Cno=@cno
    declare @prof varchar(20)
    select @prof=prof from Teacher where Tno=@tno
    if @zcount>0
    begin
    if @yxcount/@zcount>=0.5
    begin
    if @prof='教授'
    begin
    print'已经是最高级别,没法再升级了。'
    end
    if @prof='副教授'
    begin
    update Teacher set Prof='教授' where Tno=@tno
    end
    if @prof='讲师'
    begin
    update Teacher set Prof='副教授' where Tno=@tno
    end
    if @prof='助教'
    begin
    update Teacher set Prof='讲师' where Tno=@tno
    end
    if @prof='后勤'
    begin
    update Teacher set Prof='助教' where Tno=@tno
    end
    end
    else
    begin
    if @prof='教授'
    begin
    update Teacher set Prof='副教授' where Tno=@tno
    end
    if @prof='副教授'
    begin
    update Teacher set Prof='讲师' where Tno=@tno
    end
    if @prof='讲师'
    begin
    update Teacher set Prof='助教' where Tno=@tno
    end
    if @prof='助教'
    begin
    update Teacher set Prof='后勤' where Tno=@tno
    end
    end
    end
    else
    begin
    print'这个老师可能没有教课'
    end
    end
    go
    exec pingji '804'

  • 相关阅读:
    《python编程从入门到实践》变量和简单数据类型
    《初学python》
    centos7 关闭防火墙
    记几个学习资源
    servlet-api.jar
    spring 对Map的一种扩展 MultiValueMap
    CPU飚高问题解决
    聊聊数据库优化
    netty的核心组件
    【转】 一个著名的日志系统是怎么设计出来的?
  • 原文地址:https://www.cnblogs.com/mxx0426/p/4099191.html
Copyright © 2011-2022 走看看