"select
invono1,date1, vendorid1,vendor,
sum( IFNULL(qty1,0))qty1,sum( IFNULL(weight1,0) )weight1,sum( IFNULL(amt,0))amt,sum( IFNULL(prncount1,0) )prncount1,round(sum( IFNULL(amt,0))/sum( IFNULL(qty1,0)),3)junjia,round(sum( IFNULL(weight1,0))*1000/sum( IFNULL(qty1,0)),2)danzhong,sum( IFNULL(jianshu1,0) )jianshu1,sum( IFNULL(baoshu1,0) )baoshu1,sum(jianshu1 + baoshu1) AS jianbao1
from
(
select subptin1.invono invono1,subptin1.date date1,subptin1.vendorid vendorid1, vendor,subptin1.createid createid1,subptin1.lconfirma lconfirma1,subptou2.model model1,subptou2.sort sort1,subptou2.color color1,subptou2.size size1,subptou2.platsort platsort1,subptou2.cola cola1,
subptin2.qty qty1,subptin2.weight weight1,subptin2.unitpri unitpri1,round(subptin2.qty*subptin2.unitpri,2) amt,subptin2.mem mem1,subptin1.prncount prncount1,subptin2.add003 jianshu1,subptin2.add004 baoshu1,(subptin2.add003+subptin2.add004)jianbao1
,subptin1.createdt createdt1,subptin1.prndatetime prndatetime1,subptin1.confirmadt confirmadt1, subptin1.editordt editordt1
from subptin1
inner join subptin2 on subptin2.invono=subptin1.invono
inner join subptou2 on subptou2.mid=subptin2.id
inner join subptou1 on subptou1.invono=subptou2.invono
left join subvendor1 on subvendor1.vendorid=subptin1.vendorid
where
(case
when (LENGTH('"+alltrim(acond[1,1])+"')=0)
then subptin1.date=date_add(curdate(),interval 0 day)
else (subptin1.date between '"+alltrim(acond[1,1])+"' and '"+alltrim(acond[1,2])+"')
end)
and
(CASE
when (LENGTH('"+alltrim(acond[2,1])+"')=0) THEN vendorid1
ELSE invono1
END) AS dynamic_group
)as tab1 group by dynamic_group
union all
select '送货合计','','','',concat(sum(subptin2.qty),'个') ,concat(sum(subptin2.weight),'公斤'),concat(sum(round(subptin2.qty*subptin2.unitpri,2)),'元') ,concat(sum(subptin1.prncount),'次'),concat(round(sum(round(subptin2.qty*subptin2.unitpri,2))/sum(subptin2.qty),3),'均价元'),concat(round(sum(subptin2.weight)*1000/sum(subptin2.qty),2),'克'),concat(sum(subptin2.add003),'件'),concat(sum(subptin2.add004),'包'),concat(sum(subptin2.add003+subptin2.add004),'件包')
from subptin1
inner join subptin2 on subptin2.invono=subptin1.invono
inner join subptou2 on subptou2.mid=subptin2.id
inner join subptou1 on subptou1.invono=subptou2.invono
left join subvendor1 on subvendor1.vendorid=subptin1.vendorid
where
(case
when (LENGTH('"+alltrim(acond[1,1])+"')=0)
then subptin1.date=date_add(curdate(),interval 0 day)
else (subptin1.date between '"+alltrim(acond[1,1])+"' and '"+alltrim(acond[1,2])+"')
end)"为啥出错