Данные | Запрос |
PRESENTATION_STOCK_HISTORY | update hset 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; |
update hset 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; | |
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); |
Manage space
Manage content
Integrations