sql按月求和语句
selectsum(case when rq >='2015-1-1' and rq < '2015-2-1' then sl else 0 end) as '1月份',
sum(case when rq >='2015-2-1' and rq < '2015-3-1' then sl else 0 end) as '2月份',
sum(case when rq >='2015-3-1' and rq < '2015-4-1' then sl else 0 end) as '3月份'
from a2;
页:
[1]