Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Данные

Запрос

PRESENTATION_STOCK_HISTORY

update h

set end_date=cast(getdate() as date)

from PRESENTATION_STOCK_HISTORY h

where ( (isnull(PRESENTATION_1, -1) != isnull((select PRESENTATION_1 from RPM_PRESENTATION s where s.sku_id=h.sku_id and s.store_id=h.store_id), -1))

or (not exists (select 1 from RPM_PRESENTATION s where s.sku_id=h.sku_id and s.store_id=h.store_id)) )

      and end_date is null;

insert into PRESENTATION_STOCK_HISTORY (sku_id, store_id, PRESENTATION_1, start_date)

    select sku_id, store_id, PRESENTATION_1, cast(getdate() as date)

    from RPM_PRESENTATION s

    where not exists (select 1 from PRESENTATION_STOCK_HISTORY h where h.sku_id=s.sku_id and h.store_id=s.store_id and h.end_date is null);

SALES_SKU и SALES_GROUP 

Заполняется вызовом процедуры after_SALES_SKU_DAY (@sdate)

WH_VOLUME и WH_VALUE в SALES_SKU_DAY

Заполняется вызовом процедуры after_SALES_SKU_DAY (@sdate)

SKU_RANGE 

update sku_range

set end_date=getdate(), updated=getdate()

where end_date is null 

  and not exists (select 1 from sku_range_current c where sku_range.sku_id=c.sku_id and sku_range.store_id=c.store_id)

  and exists (select 1 from sku_range_current);

insert into sku_range (sku_id, store_id, start_date, updated)

select sku_id, store_id, getdate(), getdate()

from sku_range_current c

where not exists (select 1 from sku_range r where r.sku_id=c.sku_id and r.store_id=c.store_id and r.end_date is null);

  • No labels