oracle 根据里面字段的日期统计出每月总金额的sql语句怎么写在线等
如果是date型
1
2
3
select to_char(createtime,'yyyymm'),sum(totacaccount) from 表名
where to_char(createtime,'yyyy')=to_char(sysdate,'yyyy')
group by to_char(createtime,'yyyymm')
如果是字符型
1
2
3
select substr(createtime,1,7),sum(totacaccount) from 表名
where substr(createtime,1,4)=to_char(sysdate,'yyyy')
group by substr(createtime,1,7)