各位大蝦幫我check下看什么地方出錯

phon_oy 2006-08-10 12:45:18
select distinct top 100 ent.* from tblDataEntry as ent,CaseAction as ca,DunningCode as dc,TblAddress as ad,tblBankList as bl where
ent.[Our-Ref-No] = ca.[CaseRef]
and ent.[Our-Ref-No]=ad.[Our-Ref-No] and ent.[Our-Ref-No] = ad.CaseRef
and if((lower(ent.[Special-Code-3])='EARLY')or(lower( ent.[Special-Code-3])='fresh'))
begin
and(datediff(day,ent.[Receive-Date],getdate()))>51
and(datediff(day,ent.[Last-Pay-Date],getdate()))>51
and(datediff(day,ad.TransferDate,getdate()))>51
end

else
if((lower(ent.[Special-Code-3])<>'EARLY')and(lower( ent.[Special-Code-3])<>'fresh'))
begin
and(datediff(day,ent.[Receive-Date],getdate()))>60
and(datediff(day,ent.[Last-Pay-Date],getdate()))>60
and(datediff(day,ad.TransferDate,getdate()))>60
end


Server: Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'if'.
Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'and'.
Server: Msg 156, Level 15, State 1, Line 14
Incorrect syntax near the keyword 'and'.
...全文
116 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zsforever 2006-08-10
  • 打赏
  • 举报
回复
不支持if用Case when 改写,帮你改一个,还有两个自己改吧
datediff(day,ent.[Receive-Date],getdate()) > case lower( ent.[Special-Code-3]) when 'EARLY' then 51 when 'fresh' then 51 else 60 end
九斤半 2006-08-10
  • 打赏
  • 举报
回复
一个字:晕
phon_oy 2006-08-10
  • 打赏
  • 举报
回复
多謝了
zsforever 2006-08-10
  • 打赏
  • 举报
回复
select distinct top 100 ent.* from tblDataEntry as ent,CaseAction as ca,DunningCode as dc,TblAddress as ad,tblBankList as bl where
ent.[Our-Ref-No] = ca.[CaseRef]
and ent.[Our-Ref-No]=ad.[Our-Ref-No] and ent.[Our-Ref-No] = ad.CaseRef
and datediff(day,ent.[Receive-Date],getdate()) > case lower( ent.[Special-Code-3]) when 'EARLY' then 51 when 'fresh' then 51 else 60 end
and datediff(day,ent.[Last-Pay-Date],getdate()) > case lower( ent.[Special-Code-3]) when 'EARLY' then 51 when 'fresh' then 51 else 60 end
and datediff(day,ad.TransferDate,getdate()) > case lower( ent.[Special-Code-3]) when 'EARLY' then 51 when 'fresh' then 51 else 60 end

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧