环比=本月数据/上月数据,但是1到9月用substr()取出来是01~09,10~12月是正常的,假如月份参数是month,那么上月使用month-1是求不出来上月的数据的。应该怎么算上月的数据(销量)?按年、月、部门汇总销量如果不输入月m,查出来的还是每个月的数据,而不是上月数据,还有case when 要写在哪里,怎么写呢?where 1=1 ${if(len(公司)=0,"","and t6.name = '"+公司+"'")}and t3.name like '%${部门}%' ${if(len(m)=0,"and substr(t2.dbilldate,0,4) = '"+y+"'",(case when m ='01' then "and substr(t2.dbilldate,0,4)+1 = '"+y+"' and substr(t2.dbilldate,6,2) = '12'" else"and substr(t2.dbilldate,0,4) = '"+y+"' and trim(to_char(substr(t2.dbilldate,6,2)+1,'00')) = '"+m+"'" end))}group by t6.name,t3.name,substr(t2.dbilldate,0,4),substr(t2.dbilldate,6,2)order by substr(t2.dbilldate,0,4),substr(t2.dbilldate,6,2),sum(t.nnum) desc