select ${type} as 类型, RegionCnName, sum(isnull(RealWeight,0))/1000 as weightfrom ( select WorkSheetCode, RegionCnName, RealWeight, syear as 年份, syearmonth AS 月份 , SalesCompanyName, ServiceType from .. where ServiceType like '%空运%' AND RegionCnName IS NOT NULL ${if(${type} = "年份","and syear between '"+ Y1 +"' and '"+ Y2 +"' ","and syearmonth between '" + YM1 + "' and '" + YM2 + "' ")}) a group by ${type}, RegionCnName如上述语句 想达到的效果是 当${type} 为 年份时, 则为 and syear between '${Y1}' AND '${Y2}' 当{type} 为 月份时 ,则为 syearmonth between '${YM1}' and '${YM1}'哪位大神知道怎么写这段语句 ,请不吝赐教!谢谢