sql="select sum(B.销售数量) from A表 A inner join B表 B on A表.编号=B表.编号 where A表.编号=1001 and B.销售时间>销售时间"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
if not (rs.bof and rs.eof) then conn.execute ("update A表 set 数量=数量-"&rs(0)&" where 编号=1001")
rs.close:set rs=nothing