近一月客户新增常规里程数与额度比即上个月 第一天(包含)到上个月最后一天(包含)

字段是batch_date==>格式是 yyyymmdd

select replace(trunc(add_months(current_date,-1),'MM'),'-','');
+-----------+--+
| _c0 |
+-----------+--+
| 20181201 |
+-----------+--+
 select replace(trunc(current_date,'MM'),'-','');
+-----------+--+
| _c0 |
+-----------+--+
| 20190101 |
+-----------+--+
--限定条件
where batch_date >= replace(trunc(add_months(current_date,-1),'MM'),'-','') and batch_date< replace(trunc(current_date,'MM'),'-','')
05-28 00:37