日期:2014-05-17 浏览次数:20674 次
(select sum(Actual_D)from a where Month(Dtime) = month(@DTime) and year(Dtime) = year(@DTime) and delete_flag=0) as Actual_sum_m,
declare @DTime datetime
set @DTime='2013-5-25'
select sum(Actual_D)
from a
where delete_flag=0 and
Dtime between
(case when day(@DTime)>=26 then CONVERT(varchar(8),@DTime,23)+'26'
else CONVERT(varchar(8),dateadd(mm,-1,@DTime),23)+'26' end)
and
(case when day(@DTime)>=26 then CONVERT(varchar(8),dateadd(mm,1,@DTime),23)+'25'
else CONVERT(varchar(8),@DTime,23)+'25' end)