![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
create
procedure
sp_byyujing
as
declare @nj integer
--还剩下4年学籍无效,无通过门数少于5门
set @nj = year ( getdate ())
SELECT dwmc, xsjbdabplus.zymc, xsjbdabplus.bmc,xsjbdabplus.xh,xhjm, xsjbdabplus.xm,
xsjbdabplus.dh, byyshsdfb.wtgms, case when bysbxf < 0 then 0 else bysbxf end as ' 必修 ' , bysxif as ' 限修 ' , case when bysxxf < 0 then 0 else bysxxf end as ' 选修 '
FROM byyshsdfb JOIN xsjbdabplus on byyshsdfb.xh = xsjbdabplus.xh
WHERE ( @nj - cast ( left (byyshsdfb.xh, 4 ) as integer ) > 5 ) AND (byyshsdfb.wtgms < 5 ) AND
(xsjbdabplus.xjztdm = ' 1 ' )
ORDER BY dwmc,bmc,byyshsdfb.xh
GO
as
declare @nj integer
--还剩下4年学籍无效,无通过门数少于5门
set @nj = year ( getdate ())
SELECT dwmc, xsjbdabplus.zymc, xsjbdabplus.bmc,xsjbdabplus.xh,xhjm, xsjbdabplus.xm,
xsjbdabplus.dh, byyshsdfb.wtgms, case when bysbxf < 0 then 0 else bysbxf end as ' 必修 ' , bysxif as ' 限修 ' , case when bysxxf < 0 then 0 else bysxxf end as ' 选修 '
FROM byyshsdfb JOIN xsjbdabplus on byyshsdfb.xh = xsjbdabplus.xh
WHERE ( @nj - cast ( left (byyshsdfb.xh, 4 ) as integer ) > 5 ) AND (byyshsdfb.wtgms < 5 ) AND
(xsjbdabplus.xjztdm = ' 1 ' )
ORDER BY dwmc,bmc,byyshsdfb.xh
GO