SELECT w.location,s.article,a.pricetype,a.exectime,(SELECT MAX(recid)+1 FROM smpricehistory),s.itemprice,w.doctype FROM smdocuments w,smspec s, smacts a WHERE w.doctype='AC' AND w.id='АП-84000001998' AND s.docid=w.id AND s.docid=a.id /