有这些字段,天-类型字段(x,y,z三个值)-实际值-预计值,比率是聚合在除,比如聚合天到月,类型字段选x,则比率是sum(实际值)/sum(预计值),但是当不选类型字段时,则应该是值聚合月,这个SQL应该怎么写?下面这个是针对必选某个类型时 select substring(dates,1,7) mon ,category ,sum(problem_cnt) problem_cnt ,sum(problem_cnt)/sum(total_cnt) '比率' from table_x where 1=1 ${if(len(para) == 0,"","and category = '" + para+ "'")} group by 1,2 |