m = "select 序号,车号,发货单位,货物名称,毛重,皮重,净重,isnull(水分,0) 水分,isnull(杂质,0) 杂质,isnull(密度,0) 密度,净重*(1-isnull(水分-杂质,1)) 纯油" m = m & "from (select 序号,车号,发货单位,货物名称,sum(毛重)毛重 ,sum(皮重)皮重,sum(净重)净重,avg(case when [水分]>0 then [水分] end) 水分,"m = m & " avg(case when [杂质]>0 then [杂质] end) 杂质,avg(case when [密度]>0 then [密度] end) 密度 from chengzhongjilubiao group by 序号,车号,发货单位,货物名称) tem union all " m = m & "select '合计','','','',sum(毛重),sum(皮重),sum(净重),avg(case when [水分]>0 then [水分] end),avg(case when [杂质]>0 then" m = m & " [杂质] end),avg(case when [密度]>0 then [密度] end) 密度,sum(净重) *(1-avg(case when [水分]>0 then [水分] end)/100-avg(case when [杂质]>0 then [杂质] end)/100) ww" m = m & " From chengzhongjilubiao"
rs.Open m, cnn, adOpenStatic, adLockReadOnly 以上是程序的有关代码
程序中写错了吧?请示代码。
m = m & "from (select 序号,车号,发货单位,货物名称,sum(毛重)毛重 ,sum(皮重)皮重,sum(净重)净重,avg(case when [水分]>0 then [水分] end) 水分,"m = m & " avg(case when [杂质]>0 then [杂质] end) 杂质,avg(case when [密度]>0 then [密度] end) 密度 from chengzhongjilubiao group by 序号,车号,发货单位,货物名称) tem union all "
m = m & "select '合计','','','',sum(毛重),sum(皮重),sum(净重),avg(case when [水分]>0 then [水分] end),avg(case when [杂质]>0 then"
m = m & " [杂质] end),avg(case when [密度]>0 then [密度] end) 密度,sum(净重) *(1-avg(case when [水分]>0 then [水分] end)/100-avg(case when [杂质]>0 then [杂质] end)/100) ww"
m = m & " From chengzhongjilubiao"
rs.Open m, cnn, adOpenStatic, adLockReadOnly
以上是程序的有关代码