select ${IF(frequency="1","AA",IF(frequency="2","BB",IF(frequency="3","CC","")))} AS part_dt, sum(business_volume) as Sales, sum(valid_order) as TC from ( select part_dt, store_id, business_volume , valid_order from ads_platform_store_day where 1=1 ${IF(frequency="1","AND part_dt >= '"+format(dateinweek(endDate,1),'yyyyMMdd')+"' AND part_dt<= '"+format(endDate,'yyyyMMdd')+"'" , IF(frequency="2","AND part_dt >= '"+format(dateinmonth(endDate,1),'yyyyMMdd')+"' AND part_dt<= '"+format(endDate,'yyyyMMdd')+"'", IF(frequency="3","AND part_dt >= '"+format(dateinyear(endDate,1),'yyyyMMdd')+"' AND part_dt<= '"+format(endDate,'yyyyMMdd')+"'" ,"")))} and store_id in ( '${store_id}') )a 如上SQL,运行后报错: 请教一下,是否可以用参数做逻辑判断,如果不能,该怎么解决 |