求大虾们帮忙将这条语句简化掉..
时间:2011-08-24
来源:互联网
select 1 from RePlan where PlanFrequency =1 and ceiling ((datepart(day,getdate())-datePart(day,Startdate))%(IsNull(RDay,0)))=0 and (Startdate < GETDATE()) AND (GETDATE() < Enddate) AND (ClosePlan = 0) and (AutherID<>'')
union all
select 1 from RePlan where PlanFrequency=2 and charindex(convert(varchar(10),datepart(dw,getdate())),RWeek)>0 and (Startdate < GETDATE()) AND (GETDATE() < Enddate) AND (ClosePlan = 0) and (AutherID<>'')
union all
select 1 from RePlan where PlanFrequency=3 and RMType=1 and ceiling((datepart(Month,getdate())-datePart(Month,Startdate))%(IsNull(RMonth,0)))=0
and ceiling ((datepart(day,getdate())-datePart(day,Startdate))%(IsNull(RMonthDay,0)))=0 and (Startdate < GETDATE()) AND (GETDATE() < Enddate) AND (ClosePlan = 0) and (AutherID<>'')
union all
select 1 from RePlan where PlanFrequency=3 and RMType=2 and ceiling((datepart(Month,getdate())-datePart(Month,Startdate))%(IsNull(RMonthWeek,0)))=0 and
charindex(convert(varchar(10),datepart(dw,getdate())),RPerWeek)>0 and RPerDay=round((datepart(day,getdate()))/7,0,1)+1 and (Startdate < GETDATE()) AND (GETDATE() < Enddate) AND (ClosePlan = 0) and (AutherID<>'')
union all
select 1 from RePlan where PlanFrequency=2 and charindex(convert(varchar(10),datepart(dw,getdate())),RWeek)>0 and (Startdate < GETDATE()) AND (GETDATE() < Enddate) AND (ClosePlan = 0) and (AutherID<>'')
union all
select 1 from RePlan where PlanFrequency=3 and RMType=1 and ceiling((datepart(Month,getdate())-datePart(Month,Startdate))%(IsNull(RMonth,0)))=0
and ceiling ((datepart(day,getdate())-datePart(day,Startdate))%(IsNull(RMonthDay,0)))=0 and (Startdate < GETDATE()) AND (GETDATE() < Enddate) AND (ClosePlan = 0) and (AutherID<>'')
union all
select 1 from RePlan where PlanFrequency=3 and RMType=2 and ceiling((datepart(Month,getdate())-datePart(Month,Startdate))%(IsNull(RMonthWeek,0)))=0 and
charindex(convert(varchar(10),datepart(dw,getdate())),RPerWeek)>0 and RPerDay=round((datepart(day,getdate()))/7,0,1)+1 and (Startdate < GETDATE()) AND (GETDATE() < Enddate) AND (ClosePlan = 0) and (AutherID<>'')
作者: cyf0719 发布时间: 2011-08-24
先帮你顶顶。。。。。。。。。。
作者: sgzhou12345 发布时间: 2011-08-24
你想实现什么功能呀???
作者: sgzhou12345 发布时间: 2011-08-24
按不同属性做不同的查询,然后再合并起来
好像没什么问题啊
好像没什么问题啊
作者: sz_haitao 发布时间: 2011-08-24
每一段分别试一下。
作者: shijies 发布时间: 2011-08-24
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28