日期:2014-05-18 浏览次数:20454 次
(case when DATEDIFF (day, a.LeaseDateFrom,@time2) between 0 and DATEDIFF(day, LeaseDateFrom,DATEADD(day,-1, DATEADD(year,1,leasedatefrom))) then MonthRent*3 when DATEDIFF (day, a.LeaseDateFrom,@time2) between DATEDIFF(day, LeaseDateFrom,DATEADD(day,-1, DATEADD(year,1,leasedatefrom)))+1 and DATEDIFF(day, LeaseDateFrom,DATEADD(day,-1, DATEADD(year,2,leasedatefrom))) then MonthRent1*3 when DATEDIFF (day, a.LeaseDateFrom,@time2) between DATEDIFF(day, LeaseDateFrom,DATEADD(day,-1, DATEADD(year,2,leasedatefrom)))+1 and DATEDIFF(day, LeaseDateFrom,DATEADD(day,-1, DATEADD(year,3,leasedatefrom))) then MonthRent2*3 else null end)
declare @time2 date select @time2='2012.11.22' select (case when a.TypeOfPayment ='免租,递增,季度末7日前预交2、5、8、11' and DATEPART(month, @time2) in (2,5,8,11) then (case when DATEDIFF (day, a.LeaseDateFrom,@time2) between 0 and DATEDIFF(day, LeaseDateFrom,DATEADD(day,-1, DATEADD(year,1,leasedatefrom))) then MonthRent*3 when DATEDIFF (day, a.LeaseDateFrom,@time2) between DATEDIFF(day, LeaseDateFrom,DATEADD(day,-1, DATEADD(year,1,leasedatefrom)))+1 and DATEDIFF(day, LeaseDateFrom,DATEADD(day,-1, DATEADD(year,2,leasedatefrom))) then MonthRent1*3 when DATEDIFF (day, a.LeaseDateFrom,@time2) between DATEDIFF(day, LeaseDateFrom,DATEADD(day,-1, DATEADD(year,2,leasedatefrom)))+1 and DATEDIFF(day, LeaseDateFrom,DATEADD(day,-1, DATEADD(year,3,leasedatefrom))) then MonthRent2*3 else null end) else null end) from ContractTable a join PropertyTable b on a.City +a.Road +a.[Address] =b.City +b.Road +b.[Address] where and ContractRemarks like '%免租%' or ContractRemarks like '%递增%' order by b.City +b.Road +b.[Address]
declare @time2 date select @time2='2012.11.22' select (case when a.TypeOfPayment ='免租,递增,季度末7日前预交2、5、8、11' and DATEPART(month, @time2) in (2,5,8,11) and DATEDIFF (day, a.LeaseDateFrom,@time2)between 0 and DATEDIFF(day, LeaseDateFrom,DATEADD(day,-1, DATEADD(year,1,leasedatefrom))) then MonthRent*3 when a.TypeOfPayment ='免租,递增,季度末7日前预交2、5、8、11' and DATEPART(month, @time2) in (2,5,8,11)