看你这个截图应该是mssql的,临时写了个语句,凑合用吧。
select 到货月,sum(金额)as 总金额,sum(实收数量)as 总实收数量 from
(
select case when day(到货日期)>=26
then convert(varchar(6),dateadd(dd,10,到货日期),112)
else convert(varchar(6),到货日期,112) end as 到货月,*
from
(select '20131201' as 到货日期,100 as 金额,100 as 实收数量 union
select '20131226' as 到货日期,50 as 金额,50 as 实收数量) a
) x
group by 到货月
温馨提示:答案为网友推荐,仅供参考