select h.sku, h.sku_description, min( h.eai_lineNumber ) firstLine, count(*) lineCount, sum(h.extended_price) totalDollars, sum(h.case_qty) TotalCases, sum(h.lb_qty) TotalPounds from tbl_IMPORT_InvoiceHistory h with (nolock) inner join tbl_IMPORT_Exclusions e with (nolock) on e.ownerId = h.ownerId and e.ownerType = h.ownerType and e.exclusionId = h.sku and e.exclusionType = 'SKU' where h.ownerId = and h.ownerType = and h.eai_batchId = and h.fseSKUId is null group by h.sku, h.sku_description order by sum(h.extended_price) desc, lineCount desc select distinct s.sku, s.skuDesc from tbl_PRD_SKUs s with (nolock) inner join tbl_IMPORT_InvoiceHistory h with (nolock) on h.ownerId = s.ownerId and h.ownerType = s.fsl_tablecode and h.fseSKUId = s.skuId left outer join tbl_PRD_Packaging pkg with (nolock) on pkg.LinkID = s.skuId and pkg.LinkType = 'SKU' and pkg.ownerId = s.ownerId and pkg.fsl_tablecode = s.fsl_tablecode and ( pkg.master_net_weight_type = 'NET' or pkg.master_net_weight_type = 'AVG' ) and pkg.MASTER_NET_WEIGHT_UNIT = 'LB' and ISNUMERIC( pkg.master_net_weight ) = 1 where s.OwnerID = and s.fsl_tablecode = and pkg.MASTER_NET_WEIGHT is null and h.eai_batchId = order by s.sku select h.customer_number, h.customer_name, min( h.eai_lineNumber ) firstLine, count(*) lineCount, sum(h.extended_price) totalDollars, sum(h.case_qty) TotalCases, sum(h.lb_qty) TotalPounds from tbl_IMPORT_InvoiceHistory h with (nolock) inner join tbl_IMPORT_Exclusions e with (nolock) on e.ownerId = h.ownerId and e.ownerType = h.ownerType and e.exclusionId = h.customer_number and e.exclusionType = 'CUS' where h.ownerId = and h.ownerType = and h.eai_batchId = and h.fseCDR_RecordId is null group by h.customer_number, h.customer_name order by sum(h.extended_price) desc, lineCount desc select sku, sku_description, min( eai_lineNumber ) firstLine, count(*) lineCount, sum(extended_price) totalDollars, sum(case_qty) TotalCases, sum(lb_qty) TotalPounds from tbl_IMPORT_InvoiceHistory where ownerId = and ownerType = and eai_batchId = and fseSKUId is null and sku not in ( ) group by sku, sku_description order by sum(extended_price) desc, lineCount desc select customer_number, customer_name, min( eai_lineNumber ) firstLine, count(*) lineCount, sum(extended_price) totalDollars, sum(case_qty) TotalCases, sum(lb_qty) TotalPounds from tbl_IMPORT_InvoiceHistory with (nolock) where ownerId = and ownerType = and eai_batchId = and fseCDR_RecordId is null and customer_number not in ( ) and coalesce( fseCdr_recordIdStatus, '?' ) <> 'Z' group by customer_number, customer_name order by sum(extended_price) desc, lineCount desc select customer_number, customer_name, min( eai_lineNumber ) firstLine, count(*) lineCount, sum(extended_price) totalDollars, sum(case_qty) TotalCases, sum(lb_qty) TotalPounds from tbl_IMPORT_InvoiceHistory with (nolock) where ownerId = and ownerType = and eai_batchId = and fseCDR_RecordId is null and customer_number not in ( ) and fseCdr_recordIdStatus = 'Z' group by customer_number, customer_name order by sum(extended_price) desc, lineCount desc select customer_number, customer_name, min( eai_lineNumber ) firstLine, count(*) lineCount, sum(extended_price) totalDollars, sum(case_qty) TotalCases, sum(lb_qty) TotalPounds from tbl_IMPORT_InvoiceHistory with (nolock) where ownerId = and ownerType = and eai_batchId = and nullif( invoice_number, '' ) is null group by customer_number, customer_name order by sum(extended_price) desc, lineCount desc select i.fseForecastYear, i.fseForecastMonth, ter.internalSalesId, ter.name territoryName, cdr.cdr_recordId, i.customer_number, cdr.cdr_dstName, s.skuId, s.sku, s.skuDesc, sum( case_qty ) caseAmt, sum( lb_qty ) weightAmt, sum( extended_price ) dollarAmt, min( invoice_Date ) minInvoiceDate, max( invoice_Date ) maxInvoiceDate ,(i.fseEquivUnitsPerCase * i.case_qty) as totalAlt from tbl_IMPORT_InvoiceHistory i with (nolock) inner join tbl_PRD_Skus s with (nolock) on s.skuId = i.fseskuId and s.ownerId = i.ownerId and s.fsl_tablecode = i.ownerType inner join tbl_CDR_Distributors cdr with (nolock) on cdr.cdr_recordId = i.fseCDR_recordId and cdr.ownerId = i.ownerId and cdr.fsl_tablecode = i.ownerType inner join tbl_TER_Territories ter with (nolock) on ter.territoryId = cdr.cdr_territoryId and ter.ownerId = cdr.ownerId and ter.fsl_tablecode = cdr.fsl_tablecode where i.ownerId = and i.ownerType = and i.eai_batchId = group by i.fseForecastYear, i.fseForecastMonth, ter.internalSalesId, i.fseEquivUnitsPerCase, i.case_qty, ter.name, cdr.cdr_recordId, i.customer_number, cdr.cdr_dstName, s.skuId, s.sku, s.skuDesc order by fseForecastYear, fseForecastMonth, territoryName, cdr_dstName, s.sku select fseCDR_recordId, customer_number, customer_name, min( eai_lineNumber ) as firstLine, count( * ) lines from tbl_IMPORT_InvoiceHistory with (nolock) where ownerId = and ownerType = and eai_batchId = and fseCdr_recordIdStatus = 'A' group by fseCDR_recordId, customer_number, customer_name order by firstLine select sku, sku_description,fseSkuId, min( eai_lineNumber ) as firstLine, count( * ) lines from tbl_IMPORT_InvoiceHistory with (nolock) where ownerId = and ownerType = and eai_batchId = and fseSKUIdStatus = 'A' group by sku, sku_description,fseSkuId order by firstLine select sku, sku_description, unit_of_sale, sum( case_qty ) as cases_to_convertsum( lb_qty ) as lbs_to_convert, min( eai_lineNumber ) firstLine, count( * ) lines from tbl_IMPORT_InvoiceHistory with (nolock) where ownerId = and ownertype = and eai_batchId = and fseSkuId > 0 and ( ( nullif( coalesce( lb_qty, 0 ), 0 ) is null and fseCalculateLbs = 'Y' and case_qty != 0 ) ( nullif( coalesce( case_qty, 0 ), 0 ) is null and fseCalculateCases = 'Y' and lb_qty != 0 ) ) group by sku, sku_description, unit_of_sale

InvoiceHistory Processor Output

Message Summary
New Distributors#lsnumberformat( qmd_newDistributors.recordCount )#
New SKUs#lsnumberformat( qmd_newSkus.recordCount )#
Unknown SKUs#lsnumberformat( qmd_badSkus.recordCount )#
Ignored SKUs#lsnumberformat( qmd_excludedSkus.recordCount )#
SKU w/o Bgt Cats#lsnumberformat( qmd_skusWithoutBudgetCategories.recordCount )#
SKU w/o Weights#lsnumberformat( qmd_skusMissingWeights.recordCount )#
Unknown Customers#lsnumberformat( qmd_badCustomers.recordCount )#
Unknown Zero Customers#lsnumberformat( qmd_zeroCustomers.recordCount )#
Ignored Customers#lsnumberformat( qmd_excludedCustomers.recordCount )#
Missing Invoice Numbers#lsnumberformat( qmd_missingInvoiceNumbers.recordCount )#
Skipped for Week/Year#lsnumberformat( qmd_skippedSummary.recordCount )#
Can't Convert Unit of Measure#lsnumberformat( qmd_conversionIssues.recordCount )#

#MonthAsString( fseForecastMonth )# #fseForecastYear#

Territory/Customer/SKU Cases Lbs Dollars Invoice Dates Alt
#htmleditformat( internalSalesId )# - #htmleditformat( territoryName )#
#htmleditformat( customer_number )# - #htmleditformat( cdr_dstName )#
#htmleditformat( sku )# #htmleditformat( skuDesc )# #lsnumberformat( caseAmt )# #lsnumberformat( weightAmt )# #lsnumberformat( dollarAmt )# #lsdateformat( minInvoiceDate, "mm/dd/yy")# - #lsdateformat( maxInvoiceDate, "mm/dd/yy")# #lsnumberformat( totalAlt )# #lsnumberformat( 0 )#