Help for this page
select left(B.B_num,3) as JD, sum(B.B_COUNT) as Doc_Cnt, ... on P.REPORT_IMPORT_DT = B.REPORT_IMPORT_DT where B.REPORT_IMPORT_DT = '2005-10-12' group by left(b_num,3)
select left(B_num,3) as JD, count(B_Num) as BatchCount, ... from Batches where report_import_dt = '2005-11-10' and b_status in ('RD', 'RO') group by left(b_num,3)