
现在的代码是这样的:结果出现相同编号多次求和(如同一编号有3个纪录就重复3次,以此类推)
set count_sell = server.createobject("ADODB.RecordSet")
count_sell.open sql,conn,1,3
nowmoney=0
nowprice=0
zongshulian=0
do while count_sell.eof=false
sql3="select sum(price*shulian),sum(price2*shulian),sum(shulian) from tjsell where type=0 and bianhao ='"&count_sell("bianhao")&"' and zu=false"
if nowku<>"" then
sql3=sql3&" and id_ku="&nowku
end if
if nowkeyword<>"" then
sql3=sql3&" and (bianhao = '"&nowkeyword&"' or id_huiyuan in (select id from huiyuan where username like '%"&nowkeyword&"%') or id_login in (select id from login where username like '%"&nowkeyword&"%') or title like '%"&nowkeyword&"%' or huohao like '%"&nowkeyword&"%')"
end if
set rs_sum=conn.execute(sql3)
nowmoney=nowmoney+rs_sum(0)
nowprice=nowprice+rs_sum(1)
zongshulian=zongshulian+rs_sum(2)
count_sell.movenext
loop
获取得count_sell("bianhao")是多个,出来的结果当然多个
取得count_sell("bianhao")的时枣敏冲候你用group by把bianhao这个字段先分组,然后就唯一了,sql3里面也是唯凳歼一的,出来的结果也是拿汪唯一的
你这个代码是进销存的代码吧?