select sum(数量)
from (
select *,case when day(日期)>25 then dateadd(day,6,日期) 日期 end as 日期2
from tb
) t
group by 日期2