select distinct salesYear, salesMonth from tbl_IMPORT_DistributorSales where ownerId = and ownerType = and eai_batchId = order by salesYear, salesMonth update tbl_IMPORT_DistributorSales set fseForecast_Year = , fseForecast_Month = , fseFiscalYear = , fseFiscalPeriod = , fseFiscalWeek = where salesYear = and salesMonth = and eai_batchId = and ownerId = and ownerType = select distinct sku from tbl_IMPORT_DistributorSales where ownerId = and ownerType = and eai_batchId = and nullif( sku, '' ) is not null select s.sku, s.skuId, p.prodId, s.bgtCatOverride l1BgtCatOverride, s.bgtCatId l1BgtCatId, p.bgtCatId l2BgtCatId from tbl_PRD_SKUS s inner join tbl_PRD_Products p on p.prodId = s.prodId and p.ownerId = s.ownerId and p.fsl_tablecode = s.fsl_tablecode where s.sku like and s.inactive = '0' and s.ownerId = and s.fsl_tablecode = order by s.skuId update tbl_IMPORT_DistributorSales set fseSkuId = , fseSku = , fseProdId = , fseBgtCatId = where eai_batchId = and ownerId = and ownerType = and sku = select distinct customerNbr from tbl_IMPORT_DistributorSales where eai_batchId = and ownerId = and ownerType = select cdr.cdr_recordId, ter.territoryId from tbl_CDR_Distributors cdr inner join tbl_TER_Territories ter on ter.territoryId = cdr.cdr_territoryId and ter.ownerId = cdr.ownerId and ter.fsl_tablecode = cdr.fsl_tablecode where cdr.ownerId = and cdr.fsl_tablecode = and EXISTS (SELECT * FROM tbl_CDR_Dstcodes cdrd WHERE cdrd.ownerId = cdr.ownerId AND cdrd.ownerType = cdr.fsl_tablecode AND cdrd.cdr_dstcode = AND cdrd.cdr_recordid = cdr.cdr_recordid) order by cdr.cdr_recordId update tbl_IMPORT_DistributorSales set fseCdr_RecordId = , fseSalesTerritoryId = , fseDistributorStatus = 'M' where eai_batchId = and ownerId = and ownerType = and customerNbr = select cdrRDC.cdr_recordId from tbl_CDR_Distributors cdrRDC inner join tbl_DST_Distributors dstRDC on dstRDC.dstId = cdrRDC.fsl_dstId and dstRDC.dstCompanyType = 'RDC' where cdrRDC.ownerId = and cdrRDC.fsl_tablecode = select cdr.cdr_recordId, cdr.rdcVolumeShare, cdr.cdr_territoryId, cdr.cdr_dstCode, cdr.cdr_dstName from tbl_CDR_Distributors cdr inner join tbl_DST_Distributors dst on dst.dstId = cdr.fsl_dstId inner join tbl_CDR_Distributors cdrRDC on cdrRDC.fsl_dstId = dst.dstRDCId and cdrRDC.ownerId = cdr.ownerId and cdrRDC.fsl_tablecode = cdr.fsl_tablecode inner join tbl_TER_Territories ter on ter.territoryId = cdr.cdr_territoryId and ter.fsl_tablecode = cdr.fsl_tablecode and ter.ownerId = cdr.ownerId where cdrRDC.ownerId = and cdrRDC.fsl_tablecode = and cdrRDC.cdr_recordId = and cdr.rdcVolumeShare > 0.0 update tbl_IMPORT_DistributorSales set fseRDC = 'Y' where eai_batchId = and fsecdr_recordId in ( ) select eai_importId, fseFiscalYear, fseforecast_year, fseforecast_month, fseSku, fseSkuId, fseProdId, fseBgtCatId, fseCdr_recordId, fseSalesTerritoryId, sum( fseAlt ) fseAlt, sum( fseCases ) fseCases, sum( fseLbs ) fseLbs, sum( fseDollars) fseDollars from tbl_IMPORT_DistributorSales where eai_batchId = and fsecdr_recordId in ( ) and fseskuId is not null and fseForecast_year is not null and fseForecast_month is not null group by eai_importId, fseFiscalyear, fseforecast_year, fseforecast_month, fseSku, fseSkuId, fseProdId, fseBgtCatId, fseCdr_recordId, fseSalesTerritoryId insert into tbl_IMPORT_DistributorSales ( ownertype, ownerId, eai_batchId, eai_lineNumber, fseForecast_year, fseForecast_month, fseSKU, fseSKUId, fseProdId, fseBgtCatId, fseCdr_recordId, fseSalesTerritoryId, fseAlt, fseCases, fseLbs, fseDollars, fseFiscalYear, customerNbr, customerDesc, fseRDCId, fseDistributorStatus, fseRDCShare ) values ( , , , 0, , , , , , , , , , , , , , , , , '+', ) update tbl_IMPORT_DistributorSales set fseRDCAlt = , fseRDCCases = , fseRDCLbs = , fseRDCDollars = where eai_batchId = and ownerId = and ownerType = and eai_importId = select fseforecast_year, fseforecast_month, fseSku, fseSkuId, fseProdId, fseBgtCatId, fseCdr_recordId, fseSalesTerritoryId, sum( fseAlt ) fseAlt, sum( fseCases ) fseCases, sum( fseLbs ) fseLbs, sum( fseDollars) fseDollars from tbl_IMPORT_DistributorSales where eai_batchId = and fsecdr_recordId is not null and fseskuId is not null and fseForecast_year is not null and fseForecast_month is not null and fseRDC = 'N' group by fseforecast_year, fseforecast_month, fseSku, fseSkuId, fseProdId, fseBgtCatId, fseCdr_recordId, fseSalesTerritoryId update tbl_MFR_TPF_Detail#_tpfSuffix# set forecast_alt = , forecast_qty = , forecast_amt = , productItemCode = , prodId = , bgtCategoryId = , lastUpdateSource = , lastUpdate = , territoryId = where forecast_year = and forecast_month = and tPartnerType = 'CDR' and tPartnerId = and productLevel = 'SKU' and skuId = and mfr_id = and forecast_status = 'Q' insert into tbl_MFR_TPF_Detail#_tpfSuffix# ( forecast_alt, forecast_qty, forecast_amt, productItemCode, prodId, bgtCategoryId, lastUpdateSource, lastUpdate, forecast_year, forecast_month, tPartnerType, tPartnerId, skuId, productLevel, mfr_id, forecast_status, territoryId ) values ( , , , , , , , , , , 'CDR', , , 'SKU', , 'Q', ) select fseForecast_year, fseForecast_month, fseSalesTerritoryId, fseBgtCatId, sum( fseCases ) fseCases, sum( fseLbs ) fseLbs, sum( fseDollars ) fseDollars, sum( fseAlt ) fseAlt from tbl_IMPORT_DistributorSales where eai_batchId = and ownerId = and ownerType = and fseBgtCatId is not null and fseSalesTerritoryId is not null group by fseForecast_year, fseForecast_month, fseSalesTerritoryId, fseBgtCatId order by fseSalesTerritoryId, fseForecast_year, fseForecast_month update tbl_MFR_TPF_Detail#_tpfSuffix# set forecast_alt = , forecast_qty = , forecast_amt = , lastUpdateSource = , lastUpdate = where forecast_year = and forecast_month = and tPartnerType = 'TER' and tPartnerId = and bgtCategoryId = and productLevel = 'UOM' and productItemCode = and mfr_id = and forecast_status = 'Q' insert into tbl_MFR_TPF_Detail#_tpfSuffix# ( forecast_alt, forecast_qty, forecast_amt, lastUpdateSource, lastUpdate, forecast_year, forecast_month, tPartnerType, tPartnerId, bgtCategoryId, productLevel, productItemCode, mfr_id, forecast_status ) values ( , , , , , , , 'TER', , , 'UOM', , , 'Q' ) update tbl_MFR_TPF_Detail#_tpfSuffix# set forecast_alt = , forecast_qty = , forecast_amt = , lastUpdateSource = , lastUpdate = where forecast_year = and forecast_month = and tPartnerType = 'TER' and tPartnerId = and productLevel = 'UOM' and productItemCode = 'MKT_0' and mfr_id = and forecast_status = 'Q' insert into tbl_MFR_TPF_Detail#_tpfSuffix# ( forecast_alt,forecast_qty, forecast_amt, lastUpdateSource, lastUpdate, forecast_year, forecast_month, tPartnerType, tPartnerId, productLevel, productItemCode, mfr_id, forecast_status ) values ( , , , , , , , 'TER', , 'UOM', 'MKT_0', , 'Q' ) moved to utl_updateTerritorySummaries.cfm ---> select distinct fseFiscalYear fiscalYear from tbl_IMPORT_DistributorSales where eai_batchId = and fseBgtCatId is not null and fseSalesTerritoryId is not null order by fiscalYear desc select distinct fseSalesTerritoryId, fseFiscalYear fiscalYear from tbl_IMPORT_DistributorSales where eai_batchId = and fseBgtCatId is not null and fseSalesTerritoryId is not null ---> #_salesDataSharingHTML#