create table SUPPLIERARTBARCOD(ARTTICLE VARCHAR2[50], BARCODE VARCHAR2[50]); \\тут создаем новую таблицу
insert into SUPPLIERARTBARCOD(select b.article, a.barcode \\тут заполняем
from supermag.SMSupplyCase b, supermag.SMStoreUnitHist a \\штрихкодами
where a.article=b.article and b.IDSUPPLIER = '21979'); \\и артикулами поставщика
spool c:123.txt;
select article, barcode from SUPPLIERARTBARCOD \\тут
minus \\сравниваем
select b.article, a.barcode \\записи
from supermag.SMSupplyCase b, supermag.SMStoreUnitHist a \\двух
where a.article=b.article b.IDSUPPLIER = '21979'; \\таблиц
spool off;
drop table SUPPLIERARTBARCOD; \\тут удаляем новую таблицу
select a as ШК, d as Кол_артикулов from ( select a, count(c) as d from ( select barcode as a, article as b, 1 as c from SMStoreUnitHist group by barcode, article ) group by a ) where d > 1 order by a
SELECT t.barcode, t.article, t.datetime FROM (SELECT barcode, article, datetime, COUNT (*) OVER (PARTITION BY barcode) c FROM (SELECT b.article, a.barcode, MAX (a.eventtime) datetime FROM supermag.smsupplycase b, supermag.smstoreunithist a WHERE a.article = b.article AND b.idsupplier = 21979 GROUP BY b.article, a.barcode)) t WHERE t.c > 1 ORDER BY t.barcode, t.datetime;