select mfr_id, mfr_name from tblManufacturers mfr with (nolock) where exists ( select * from tbl_MFR_TPF_Detail#_tpfSuffix# tpf with (nolock) where tpf.mfr_id = mfr.mfr_id and forecast_status = 'A' and tpartnerType = 'CDR' and forecast_year = '2017') order by mfr_name
select ter.territoryId, ter.name from tbl_TER_Territories ter with (nolock) inner join tbl_TER_TerritoryLevels lvl with (nolock) on lvl.levelId = ter.levelId and lvl.ownerId = ter.ownerId and lvl.fsl_tablecode = ter.fsl_tablecode and lvl.brokerLevel = 1 where ter.ownerId = and ter.fsl_tablecode = 'MFR' order by ter.name select cdr.cdr_recordId, cdr.cdr_dstName from tbl_CDR_Distributors cdr with (nolock) where cdr.ownerId = and cdr.fsl_tablecode = 'MFR' and cdr.cdr_dstCompanyType = 'P' and cdr.fsl_dstId > 0 order by cdr.cdr_dstName
select name from qmd_territories where territoryId = select cdr_dstName as name from qmd_parentDistributors where cdr_recordId = select cdrb.cdr_recordId, cdrb.cdr_dstName, cdrb.cdr_dstCode from tbl_CDR_Distributors cdr with (nolock) inner join tbl_DST_Distributors dstb with (nolock) on dstb.dstParentCo = cdr.fsl_dstId inner join tbl_CDR_Distributors cdrb with (nolock) on cdrb.ownerId = cdr.ownerId and cdrb.fsl_tablecode = cdr.fsl_tablecode and cdrb.fsl_dstId = dstb.dstId where cdr.ownerId = and cdr.fsl_tablecode = 'MFR' and cdr.cdr_recordId = and cdr.fsl_dstId > 0 and exists ( select * from tbl_MFR_TPF_Detail#_tpfSuffix# tpf with (nolock) where mfr_id = cdrb.ownerId and tpartnerId = cdrb.cdr_recordId and tpartnerType = 'CDR' and forecast_status = 'A') select cdr_recordId, cdr_dstName, cdr_dstCode from tbl_CDR_Distributors with (nolock) where ownerId = and fsl_tablecode = 'MFR' and cdr_territoryId = and exists ( select * from tbl_MFR_TPF_Detail#_tpfSuffix# tpf with (nolock) where mfr_id = ownerId and tpartnerId = cdr_recordId and tpartnerType = 'CDR' and forecast_status = 'A') select cdr.cdr_dstName, cdr.cdr_dstCode, tpf.tpartnerId, tpf.skuId, sum( tpf.forecast_qty ) / 12 avgMonthlyCases from tbl_MFR_TPF_Detail#_tpfSuffix# tpf with (nolock) inner join tbl_CDR_Distributors cdr with (nolock) on cdr.ownerId = tpf.mfr_id and cdr.fsl_tablecode = 'MFR' and cdr.cdr_recordId = tpf.tpartnerId where tpf.tpartnerId in ( ) and tpartnerType = 'CDR' and tpf.forecast_status = 'A' and ( ( tpf.forecast_year = and convert( int, tpf.forecast_month ) >= ) or ( tpf.forecast_year = and convert( int, tpf.forecast_month ) <= ) ) and tpf.mfr_id = group by cdr.cdr_dstName, cdr.cdr_dstCode, tpf.tpartnerId, tpf.skuId select skuId, count( * ) ranking from qmd_sales group by skuId order by ranking desc select skuId, #_by#( avgMonthlyCases ) ranking from qmd_sales group by skuId order by ranking desc select sku, skuId, skuDesc, 0 ranking from tbl_PRD_Skus with (nolock) where ownerId = and fsl_tablecode = 'MFR' and skuId in ( ) select * from qmd_top10Skus order by ranking desc select * from qmd_sales where skuId in ( ) select * from qmd_salesCrossTab order by cdr_dstName
#_periodName# (#lsdateformat( _periodRangeStart, "MM/DD/YYYY" )# - #lsdateformat( _periodRangeEnd, "MM/DD/YYYY" )#)
Distributor Top #qmd_top10SKUs.recordCount# SKUs by Accumulated Avg Monthly SalesAveraged Avg Monthly Sales## DistributorsAvg Monthly Sales
#htmleditformat( sku )#
#htmleditformat( cdr_dstName )# #lsnumberformat( _v )#