the issue is that for one customer, they don't have their invoices processed, so they don't get into history. The following SQL creates a report in Reporting Servics, you can see they have incompete data for census and billing, they only have quotes.
IV00101.ITMGEDSC,
IV00101.ITEMDESC,
RM00101.CUSTNAME,
RM00101.CPRCSTNM,
IV40600.UserCatLongDescr as UserCatLongDescr_IV40600,
CATS.UserCatLongDescr as UserCatLongDescr_CATS,
SOP10200.ITEMNMBR,
SOP10200.SOPNUMBE,
SOP10200.QUANTITY,
SOP10200.OXTNDPRC,
SOP10200.SOPTYPE,
SOP10100.DOCDATE,
'Current' as source
SOP10200 INNER JOIN IV00101 IV00101 ON
SOP10200.ITEMNMBR=IV00101.ITEMNMBR)
SOP10100 SOP10100 ON
(SOP10200.SOPTYPE=SOP10100.SOPTYPE) AND
(SOP10200.SOPNUMBE=SOP10100.SOPNUMBE))
IV40600 IV40600 ON
IV00101.ITMGEDSC=IV40600.USCATVAL)
IV40600 CATS ON
IV00101.USCATVLS_2=CATS.USCATVAL)
RM00101 RM00101 ON
SOP10100.CUSTNMBR=RM00101.CUSTNMBR Where SOP10100.DOCDATE between @FromDate and @ToDate and
RM00101.CPRCSTNM = @Customer and CATS.UserCatLongDescr <> ''
IV00101.ITMGEDSC,
IV00101.ITEMDESC,
RM00101.CUSTNAME,
RM00101.CPRCSTNM,
IV40600.UserCatLongDescr,
CATS.UserCatLongDescr,
SOP30300.ITEMNMBR,
SOP30300.SOPNUMBE,
SOP30300.QUANTITY,
SOP30300.OXTNDPRC,
SOP30300.SOPTYPE,
SOP30200.DOCDATE,
'History' as source
SOP30300 LEFT OUTER JOIN IV00101 IV00101 ON
SOP30300.ITEMNMBR=IV00101.ITEMNMBR)
SOP30200 SOP30200 ON
(SOP30300.SOPTYPE=SOP30200.SOPTYPE) AND
(SOP30300.SOPNUMBE=SOP30200.SOPNUMBE))
IV40600 IV40600 ON
IV00101.ITMGEDSC=IV40600.USCATVAL)
IV40600 CATS ON
IV00101.USCATVLS_2=CATS.USCATVAL)
RM00101 RM00101 ON
SOP30200.CUSTNMBR=RM00101.CUSTNMBR
Where SOP30200.DOCDATE between @FromDate and @ToDate and
RM00101.CPRCSTNM = @Customer and CATS.UserCatLongDescr <> ''
*This post is locked for comments