zoukankan      html  css  js  c++  java
  • 创建一个存储过程,查询在校生

    一直都是临时写语句,现在一次性建立存储过程,日后直接调用就好。

    create procedure sp_zaixiao
     
    as
    declare @curyear int
    declare @curmonth int 
    declare @tolrow int
    declare @strsql varchar(200)
    set @curyear=year(getdate())
    set @curmonth=month(getdate())
    if @curmonth>7 
     
    select case
            
    when dwdm='4420000' then '校本部'
            
    else '分校'
            
    end as '单位',
                
    count(xh) as '人数' from xsjbdab where xjztdm='1' and nj>(@curyear-3)  and xslbdm<>'61'
            
    group by (case
            
    when dwdm='4420000' then '校本部'
            
    else '分校'
            
    end)
    else
      
    select case
            
    when dwdm='4420000' then '校本部'
            
    else '分校' end as '单位',
             
    count(xh) as '人数' from xsjbdab where xjztdm='1'   and xslbdm<>'61'
                 
    and( nj>(@curyear-3or (nj=(@curyear-3and zsjj='3'))
       
    group by (case
            
    when dwdm='4420000' then '校本部'
            
    else '分校'
            
    end)

  • 相关阅读:
    java基础知识
    谈谈休眠/睡眠/关机和laptop硬件寿命
    常用的git指令查询
    java swing scroll can not work
    不必要的windows服务
    工作分配问题
    回溯算法
    第四章上机实践
    算法第四章作业
    第三章上机实践
  • 原文地址:https://www.cnblogs.com/samsonleung/p/1239809.html
Copyright © 2011-2022 走看看