select product_type, responsibility_category, sum(returned_quantity) as exodus_rate, multiIf('${type}'='订单付款后时间',toYear(toDate(order_payment_time)), '${type}'='支付时间',toYear(toDate(payment_date)), '${type}'='分厂时间',toYear(toDate(branch_date))) as tyear, multiIf('${type}'='订单付款后时间',toMonth(toDate(order_payment_time)), '${type}'='支付时间',toMonth(toDate(payment_date)), '${type}'='分厂时间',toMonth(toDate(branch_date))) as tmonthfrom various_responsibilitieswhere multiIf('${type}'='订单付款后时间',order_payment_time, '${type}'='支付时间',payment_date, '${type}'='分厂时间',branch_date) between toStartOfMonth(subtractMonths(toDate('${end_time}'),4)) and subtractMonths(toDate('${end_time}'),0) ${lf(type=="订单付款后时间","and order_payment_time<='"+end_time+"'", if(type=="支付时间","and payment_date<='"+end_time+"'", if(type=="分厂时间","and branch_date<='"+end_time+"'",'')))}GROUP BY product_type,responsibility_category,tyear,tmonth