select ${type} as 类型, RegionCnName, sum(isnull(RealWeight,0))/1000 as weight from ( select WorkSheetCode, RegionCnName, RealWeight, syear as 年份, syearmonth AS 月份 , SalesCompanyName, ServiceType from [DW_CAMS].[dbo].[DWD_ORDERS] 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}' 哪位大神知道怎么写这段语句 ,请不吝赐教!谢谢 |
最佳回答 |
||||
0
|
|