select 时间,sum(数量) from (select to_char(时间,'yyyy-mm') 时间,数量 from tbname ) group by  时间;