hello, So this statement gets me the top level (of this specific BOM being G7C-EU2):
SELECT ITEMS.FULL_NAME, BILL_OF_MATERIALS.NAME, ITEMS.PURCHASEDESCRIPTION, BOM_REVISION_COMPONENTS.QUANTITY, BOM_REVISION_COMPONENTS.ITEM_ID
FROM BOM_REVISION_COMPONENTS
JOIN BOM_REVISIONS ON BOM_REVISIONS.BOM_REVISION_ID = BOM_REVISION_COMPONENTS.BOM_REVISION_ID
JOIN BILL_OF_MATERIALS ON BILL_OF_MATERIALS.BILL_OF_MATERIALS_ID = BOM_REVISIONS.BILL_OF_MATERIALS_ID
JOIN ITEMS ON ITEMS.ITEM_ID = BOM_REVISION_COMPONENTS.ITEM_ID
WHERE BILL_OF_MATERIALS.NAME LIKE ‘G7C-EU2%’
I then need to do a recursive search to get the children which should be accomplished by a “WITH” statement. I can’t get the “WITH” statement to work at all. I created a very simple one just to test if NetSuite SuiteAnalytics Connect would allow it but I don’t think it supports CTEs.
This string doesn’t apply to a BOM, it’s just a test query:
WITH CTE AS
(SELECT ITEMS.FULL_NAME, ITEMS.ITEM_ID
FROM ITEMS
)
SELECT ITEMS.PURCHASEDESCRIPTION
FROM ITEMS i, CTE c
WHERE i.ITEM_ID = c.ITEM_ID