select formatId from tbl_EAI_inboundFileFormats with (nolock) where ownerId = and ownerType = and formatName = select listId from tbl_LST_PartnerLists with (nolock) where listName = 'Chain Reporting List of Accounts' and ownerId = and ownerType = select fiscalYear, lastInvoiceDate from tbl_CRM_FiscalCalendar with (nolock) where lastInvoiceDate is not null and ownerId = and ownerType = order by lastInvoiceDate desc ( convert( int, tpf.forecast_year ) = and convert( int, tpf.forecast_month ) >= ) or ( convert( int, tpf.forecast_year ) = and convert( int, tpf.forecast_month ) <= ) or ( convert( int, tpf.forecast_year ) = and convert( int, tpf.forecast_month ) >= ) or ( convert( int, tpf.forecast_year ) = and convert( int, tpf.forecast_month ) <= ) ) group by ct.contractId, opr.mfrCustNum, cdr.cdr_dstCode, s.sku, tpf.forecast_year, tpf.forecast_month order by ct.contractId, chain_code, cust_num, item, sales_month ---> select ct.contractId, 'act' as trans_type, gpo.mfrCustNum as chain_code, cdr.cdr_dstCode as cust_num, s.sku as item, sum( tpf.forecast_qty ) as case_qty, sum( tpf.forecast_amt ) as dollar_value, cast( forecast_month + '/15/' + forecast_year as date ) as sales_month, cdr.cdr_dstName as cust_name, s.skuDesc as item_desc, gpo.companyName as chain_name from tbl_MFR_TPF_Detail tpf with (nolock) inner join tbl_PRD_SKus s with (nolock) on s.skuId = tpf.skuId and s.ownerId = tpf.mfr_id and s.fsl_tablecode = -- and s.sku = '0620' inner join tbl_TPM_Requests r with (nolock) on r.requestId = tpf.rebateContractId and r.ownerId = tpf.mfr_id and r.ownerType = inner join tbl_TPM_Contracts ct with (nolock) on ct.contractId = r.contractId and ct.ownerId = r.ownerId and ct.ownertype = r.ownerType and ct.partnerType = 'OPR' inner join tbl_CRM_Affiliations a with (nolock) on a.ownerId = tpf.mfr_id and a.ownerType = '#qmd_batch.ownerType#' and a.partnerId = tpf.tPartnerId and a.partnerType = tpf.tPartnerType inner join tbl_OPR_ClientOperators gpo with (nolock) on gpo.operatorId = a.orgId and gpo.ownerId = a.ownerId and gpo.fsltablecode = a.ownerType and nullif( gpo.mfrCustNum, '' ) is not null and exists ( select * from tbl_LST_PartnerListItems pli with (nolock) where pli.listId = and pli.partnerId = gpo.operatorId ) inner join tbl_CDR_Distributors cdr with (nolock) on cdr.cdr_recordId = tpf.qualifierId and cdr.ownerId = tpf.mfr_id and cdr.fsl_tablecode = '#qmd_batch.ownerType#' and 'CDR' = tpf.qualifierType and nullif( cdr.cdr_dstCode, '' ) is not null where tpf.mfr_id = and tpf.forecast_status = 'C' and tpf.tpartnerType = 'OPR' and ( ( convert( int, tpf.forecast_year ) = and convert( int, tpf.forecast_month ) >= ) or ( convert( int, tpf.forecast_year ) = and convert( int, tpf.forecast_month ) <= ) or ( convert( int, tpf.forecast_year ) = and convert( int, tpf.forecast_month ) >= ) or ( convert( int, tpf.forecast_year ) = and convert( int, tpf.forecast_month ) <= ) ) group by ct.contractId, gpo.mfrCustNum, cdr.cdr_dstCode, s.sku, tpf.forecast_year, tpf.forecast_month, cdr.cdr_dstName, s.skuDesc, gpo.companyName order by ct.contractId, chain_code, cust_num, item, sales_month
#_r.sql#
select trans_type, chain_code, cust_num, item, cust_name, item_desc, chain_name, sum( case_qty ) as case_qty, sum( dollar_value ) dollar_value, sales_month from qmd_source group by trans_type, chain_code, cust_num, item, sales_month, cust_name, item_desc, chain_name order by chain_code, cust_num, item, sales_month select * from qmd_actuals where trans_type = '' select #qmd_actuals.columnList# from qmd_actuals union all select #qmd_lag.columnList# from qmd_lag order by chain_code, cust_num, item, sales_month select ftpDirectory, ftpPassword, ftpServer, ftpUserName from tbl_EAI_InboundFTPSources where ftpDirectory = 'fse' and ownerId = and ownerType =

Development Environment: FTP Transfer Disabled

update tbl_EAI_inboundBatches set fileName = where batchId =