DKS892DJDSAw(提问者) 回复 Z4u3z1select * from(
select *
from ADS_TARGET_DLSXMLBS
where
1=1
${if(len(headshopid) == 0,\"\",\"and dept in (\'\" + headshopid + \"\')\")}
${if(len(shopid) == 0,\"\",\"and shopid in (\'\" + shopid + \"\')\")}
and to_char(saledate,\'YYYY-MM-DD\') >=\'${date1}\'
and to_char(saledate,\'YYYY-MM-DD\') <=\'${date2}\'
) ta
order by ta.je ${a}
Z4u3z1 回复 DKS892DJDSAw(提问者)
假设你模板上B4 用的是 categoryid
select * from( select categoryid,sum(je) as je,sum(bs) as bs,sum(ml) as ml from ADS_TARGET_DLSXMLBS where 1=1 ${if(len(headshopid) == 0,\"\",\"and dept in (\'\" + headshopid + \"\')\")} ${if(len(shopid) == 0,\"\",\"and shopid in (\'\" + shopid + \"\')\")} and to_char(saledate,\'YYYY-MM-DD\') >=\'${date1}\' and to_char(saledate,\'YYYY-MM-DD\') <=\'${date2}\' group by categoryid ) ta order by ta.je ${a}