双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

一个sql语句,求高手过来看看如何写

t_sheng t_sheng 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
想写个存储过程,传两个参数 :一个 时间,还有一个是周期数
有个表里有两个时间,cr.tabDate 有可能是空的,下面的where中case怎么写
关键是
(case ISNULL(cr.tabDate,0)
when 0 then select datediff(DAY,cr.billdate,@nowData) = @day
else (select datediff(DAY,cr.tabDate,@nowData)) = @day
end)

要怎么加

create procedure ud_getRemindRepair
@nowData datetime,
@day varchar
as

select gr.billid,cr.code,cr.billdate,cr.Mobile from goodsrecord gr
left join clientrepair cr on cr.repairid=gr.billid
where ISNULL(gr.goodshabitus,0)=0 and ISNULL(gr.vrhabitus,0)=0 and notetype=50 and
(case ISNULL(cr.tabDate,0)
when 0 then select datediff(DAY,cr.billdate,@nowData) = @day
else (select datediff(DAY,cr.tabDate,@nowData)) = @day
end)
group by gr.billid,cr.code,cr.billdate,cr.Mobile
...全文
评论 4
收藏 已收藏
分享
返回顶部
t_sheng
C# 111,129 成员 642,540 内容