insert into smpricehistory(storeloc,article,pricetype,eventtime,recid,price,doctype,docid) select w.location,s.article,a.pricetype,a.exectime,(select max(recid)+1 from smpricehistory),s.itemprice,w.doctype,w.id from smdocuments w,smspec s, smacts a where w.doctype='AC' and w.id in ('АП-82000002001', 'АП-60000002004', 'АП-65000002000', 'АП-79000001999', 'АП-64000002000', 'АП-61000002000', 'АП-75000002099') and s.docid=w.id and s.docid=a.id /