select sku, mfrId, skuId from tbl_PRD_Skus with (nolock) where ownerid = and fsl_tablecode = and skuId = select cdr_dstname, cdr_dstCode, cdr_recordId from tbl_cdr_distributors with (nolock) where ownerid = and fsl_tablecode = and cdr_recordId = select distributorItemCode from #ERPDatabaseName#.distributoritemhistories ih with (nolock) inner join #ERPDatabaseName#.items itm with (nolock) on itm.itemid = ih.itemid inner join #ERPDatabaseName#.manufacturers mfr with (nolock) on mfr.manufacturerid = itm.manufacturerid inner join #ERPDatabaseName#.distributors dst with (nolock) on dst.distributorid = ih.distributorid where itm.itemcode = and mfr.manufacturercode in () and dst.distributorcode = select cdrp.cdr_recordId, cdrp.cdr_dstName from tbl_CDR_DstCodes cdrc with (nolock) inner join tbl_CDR_Distributors cdrb with (nolock) on cdrb.cdr_recordId = cdrc.cdr_recordId inner join tbl_DST_Distributors dstb with (nolock) on dstb.dstId = cdrb.fsl_dstId and coalesce( dstb.dstparentCo, 0 ) > 0 inner join tbl_CDR_Distributors cdrp with (nolock) on cdrp.fsl_dstId = dstb.dstParentCo and cdrp.ownerId = cdrb.ownerId and cdrp.fsl_tablecode = cdrb.fsl_tablecode where cdrc.cdr_dstCode = and cdrc.ownerId = and cdrc.ownerType = ---> select customerSKU from tbl_PRD_CustomerSKUs with (nolock) where customerType= 'PDST' and skuId = and ownerId = and fsl_tablecode = and customerId = ---> select cs.customerSKU from tbl_DW_CustomerSKUs#_tableSuffix# cs with (nolock) where skuId = and cdr_recordId =
Distributor:#HTMLEditFormat(qcf_dist.distributorname)#
Dist Item Code:No Code#htmleditformat( _distributorItemCode )#
Last Five Orders for #htmleditformat( _skuCd )#
#_colHeader# Days Past Quantity Price Order Number Invoice Number
#dateformat(orderdate,"mm/dd/yyyy")# #dateformat(reportShipDate,"mm/dd/yyyy")# #numberformat(datediff("d",orderdate,now()),"9,999")# #numberformat(datediff("d",reportShipDate,now()),"9,999")# #numberformat(quantity,"9,999")# #numberformat(price,"9,999.99")# #htmleditformat(ordernumber)# #htmleditformat(invoicenumber)#