select sum(数量) as 'sum_' from table WHERE 1=1 ${IF(type_=="当月"," AND 日期字段>='"+DATE(year(today()),月份控件,1)+"'"," AND 日期字段>='"+DATE(year(today()),1,1)+"'")} AND 日期字段<='${DATEINMONTH(DATE(year(today()),月份控件,1),-1)}'
${if(参数='当月'," and left(日期字段,8)=left(current_date,8)",if(参数="累计"," and 日期字段>=left(current_date,4)||'-01-01' and left(日期字段,8)<=left(current_date,8)",""))}