Запросик "веселенький", но работает, не нужные поля можно убрать, внимание обрати на opcode, docstate, createdat, accepted, datatype.
SQL код:
select t.name азс, t.createdat дата_последнего_прихода, t.article артикул, t.nameA название, t.itemprice цена_в_приходной, t.N1 процент_наценки,
ceil(t.itemprice * (1+N1/100)) цена_с_наценкой, t.price цена_на_азс, t.price - ceil(t.itemprice * (1+N1/100)) разница
from
(
select l.name, d.createdat, s.article, c.name nameA, s.itemprice, p.price, SMGetExtraChargeClass(s.article, '0') N1,
row_number() over (partition by d.locationto, s.article order by d.createdat desc, d.id desc) RN
from smdocuments d, smspec s, smstorelocations l, smcard c, smprices p
where d.doctype = s.doctype
and l.id = d.locationto
and d.id = s.docid
and d.docstate = 3
and d.opcode = 0
and d.doctype = 'WI'
and d.createdat > to_date('01.01.2014','dd.mm.yyyy')
and s.article = c.article
and c.accepted = 1
and c.datatype = 0
and p.storeloc = l.id
and p.article = c.article
) t
where RN = 1
and ceil(t.itemprice * (1+N1/100)) - t.price <> 0
order by t.name, t.price - ceil(t.itemprice * (1+N1/100))