Inventory Report of Products and their Components etc.

The accessories and components are stored in a table called tblBill and link back to the main inventory master table tnlInvmas. 

The easiest way of creating this report will be by an Excel ODC query as per the instructions on the knowledge base at the link below. 

How to use Excel Query Builder



SELECT I.groupfld                 AS [Parent Group],
       PG.group_descv6           AS [Parent Group Description],
       I.category                     AS [Parent Category],
       PC.cat_descv6               AS [Parent Category Description],
       I.subcategory                AS [Parent Sub Category],
       Isnull(PSC.cat_descv6, '') AS [Parent Sub Category Description],
       B.parent_code               AS [Parent Code],
       I.descriptionv6              AS [Parent Description],
       I2.groupfld                   AS [Child Group],
       CG.group_descv6          AS [Child Group Description],
       I2.category                  AS [Child Category],
       CC.cat_descv6              AS [Child Category Description],
       I2.subcategory             AS [Child Sub Category],
       Isnull(CSC.cat_descv6, '') AS [Child Sub Category Description],
       B.product_code             AS [Child Code],
       I2.descriptionv6           AS [Child Description],
       B.qty_v5                     AS [Child Qty]
FROM   tblbill B
       LEFT OUTER JOIN tblinvmas I
                    ON I.product_code = B.parent_code
       LEFT OUTER JOIN tblgroup PG
                    ON PG.group_code = I.groupfld
       LEFT OUTER JOIN tblcategory PC
                    ON PC.category_code = I.category
       LEFT OUTER JOIN tblcategory PSC
                    ON PSC.category_code = I.subcategory
       LEFT OUTER JOIN tblinvmas I2
                    ON I2.product_code = B.product_code
       LEFT OUTER JOIN tblgroup CG
                    ON CG.group_code = I2.groupfld
       LEFT OUTER JOIN tblcategory CC
                    ON CC.category_code = I2.category
       LEFT OUTER JOIN tblcategory CSC
                    ON CSC.category_code = I2.subcategory
WHERE  I.product_type_v41 = 0
ORDER  BY I.groupfld,
          I.category,
          I.subcategory,
          B.parent_code,
          B.sub_seq_no